Check member list to display specific content in a module

SOLVE
iliascarre
Participant | Gold Partner

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 Accepted solution

Accepted Solutions
iliascarre
Solution
Participant | Gold Partner

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... 

View solution in original post

2 Replies 2
dennisedson
Community Manager

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 🙃)

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
iliascarre
Solution
Participant | Gold Partner

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... 

View solution in original post