CMS Development

iliascarre
Teilnehmer/-in | Platinum Partner
Teilnehmer/-in | Platinum Partner

Check member list to display specific content in a module

lösung

Hi,

I am editing this post as I found a solution after posting this.😀 I hope this may help others: 

 

I based my original logic using the if statement referenced in this post: https://community.hubspot.com/t5/CMS-Development/If-statement-to-check-list-contact-membership-statu... and it was working fine but within the last month has stopped working for me. I even slimmed the code down to a very basic test and it was still not working. My basic test code: 

 

{% if module.list_id in request_contact.list_memberships %}
{#========== CONTENT WHEN ON THE LIST ==========#}
  <div>
    I am ON the list
  </div>
{#========== CONTENT WHEN NOT ON THE LIST ==========#}
{% else %}
  <div>
    I am NOT on the list
  </div>
{% endif %}

 

 

I have the list_id text field in the module and I am on the list so should see the approved content but was not. 

1 Akzeptierte Lösung
iliascarre
Lösung
Teilnehmer/-in | Platinum Partner
Teilnehmer/-in | Platinum Partner

Check member list to display specific content in a module

lösung

SOLUTION:

{% set list_variable = request_contact.list_memberships %}
{% if module.list_id in list_variable %}

yes, you are in the list

{% else %}

No, you are not in the list

{% endif %}

I am not sure why the other one stopped but this seems to do the trick right now. I found this solution here: https://stackoverflow.com/questions/63190863/hubl-how-to-check-what-lists-a-contact-is-part-of-by-co... 

Lösung in ursprünglichem Beitrag anzeigen

5 Antworten
PatKeo
Teilnehmer/-in | Diamond Partner
Teilnehmer/-in | Diamond Partner

Check member list to display specific content in a module

lösung

Hi @iliascarre just wondering if you know if this will work in a blog post? I've setup a boolean to check if it is 'member content' and if true, then to run this list check you have provided, and if not in list then to show a different message. I have added myself to this test list but I am still seeing the sorry message.

 

This is what I've got:

 

 <div class="blog-body-1__content">
{% boolean "membercontent" label='Member content', value=False, no_wrapper=True, export_to_template_context=True %}
{% set membercontent = widget_data.membercontent.value %}
{% if membercontent %}
{% set module.list_id = 6 %}
{% set list_variable = request_contact.list_memberships %}
{% if module.list_id in list_variable %}
{{ content.post_body }}
{% else %}
Sorry, you must be a member to view this content.
{% endif %}
{% else %}
{{ content.post_body }}
{% endif %}
</div>

 

0 Upvotes
iliascarre
Teilnehmer/-in | Platinum Partner
Teilnehmer/-in | Platinum Partner

Check member list to display specific content in a module

lösung

Hi @PatKeo I am not sure if it will work for blog posts. Mine was specific to a module with enclosed content so not sure what you might have to tweak to get it to work in your situation. 

0 Upvotes
iliascarre
Lösung
Teilnehmer/-in | Platinum Partner
Teilnehmer/-in | Platinum Partner

Check member list to display specific content in a module

lösung

SOLUTION:

{% set list_variable = request_contact.list_memberships %}
{% if module.list_id in list_variable %}

yes, you are in the list

{% else %}

No, you are not in the list

{% endif %}

I am not sure why the other one stopped but this seems to do the trick right now. I found this solution here: https://stackoverflow.com/questions/63190863/hubl-how-to-check-what-lists-a-contact-is-part-of-by-co... 

samanthamclean
Mitglied

Check member list to display specific content in a module

lösung

Hi @iliascarre!

 

 I've been looking at designing some emails in BeeFree.io HTML builder because a) it integrates into Hubspot (we are new users migrating from Activecampaign) and b) the overall email size comes out smaller so there is no clipping in Gmail.

 

So I wondered if you might have the answers to a couple of questions I have:

 

  1. I have got your solution above to work in BeeFree when the user is a member of the list. See image https://gyazo.com/0f447cec1f8705bbb7141e5143730642/// But wondering what the command would be to do the opposite - ie when a user is not in the list?
  2. And in the above example, the list number is 1 but what would show if a different contact was, say a member of list 11 or 21? - would it still work?

You might be my last hope on an easy solution to this one so I am crossing my fingers. Or would love to be pointed in the direction of someone that can help. Thanks in advance. Cheers, Sam.

 

0 Upvotes
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

Check member list to display specific content in a module

lösung

Thanks for posting the solution , @iliascarre 

If you add a response here, we can accept it as the solution (I know that the first post is the solution, but the system won't let us use that as the solution 🙃)