# PHP if user is on a list

**URL:** <https://community.hubspot.com/t/php-if-user-is-on-a-list/64265>\
**Category:** APIs & Integrations\
**Tags:** php, contacts, webhooks\
**Created:** [September 1, 2022, 12:53pm UTC](https://community.hubspot.com/t/php-if-user-is-on-a-list/64265 "2022-09-01T12:53:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flow1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/flow1/32/38114_2.png) [@Flow1](https://community.hubspot.com/u/Flow1)\
**Post date:** [September 1, 2022, 12:53pm UTC](https://community.hubspot.com/t/php-if-user-is-on-a-list/64265/1 "2022-09-01T12:53:34Z")

</div>

Using the API and PHP how can we show content or give access to areas based on if a user is on a Hubspot list or not. For example:

```lia-code-sample
if (user is on list YYY) {

 show THIS

} else {

 show THAT
}

```

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [September 2, 2022, 1:17pm UTC](https://community.hubspot.com/t/php-if-user-is-on-a-list/64265/2 "2022-09-02T13:17:11Z")

</div>

If possible you may not need PHP at all. HubSpot exposes the lists a contact is associated with in a page request variable called r[equest\_contact.list\_memberships](https://developers.hubspot.com/docs/cms/hubl/variables#:~:text=disable%20page%20caching.-,request_contact.list_memberships,will%20disable%20page%20caching.,-content.language). That may not work for your use case though. I think the other option is to use the [lists API](https://legacydocs.hubspot.com/docs/methods/lists/get_list_contacts) to get the contacts in a specific list and then see if the one you have is in it. I’d be interested to know if there is a better way.
