Title: Conditional for restricted post
Last modified: January 29, 2021

---

# Conditional for restricted post

 *  Resolved [chugs](https://wordpress.org/support/users/chugs/)
 * (@chugs)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/conditional-for-restricted-post/)
 * Is there a conditional that can be used within the post loop to test whether 
   the post is member restricted or not?
 * For ex.
 *     ```
       is_pmpro_restricted_post() {
       ..do something..
       } else {
       …do something else..
       }
       ```
   
 * OR
 *     ```
       post_has_pmpro_level (1) {
       ..do something..
       } else {
       …do something else..
       }
       ```
   
 * Thanks
 * WordPress v5.2.8
    PHP v7.3 Paid Memberships Pro – v2.5.2

Viewing 1 replies (of 1 total)

 *  Plugin Author [Andrew Lima](https://wordpress.org/support/users/andrewza/)
 * (@andrewza)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/conditional-for-restricted-post/#post-13985240)
 * Hi [@chugs](https://wordpress.org/support/users/chugs/)
 * Thank you for using paid Memberships Pro.
 * You would need to query the database using the post ID to see what levels the
   post belongs to in the `_pmpro_membership_pages` table.
 * A workaround would be to use the [pmpro_has_membership_access_filter](https://www.paidmembershipspro.com/hook/pmpro_has_membership_access_filter/)
   to see if the user has access to the content and filter content accordingly.
 * Another option would be to use the `pmpro_hasMembershipLevel` function inside
   the loop and restrict it based on level requirements as per this guide – [https://www.paidmembershipspro.com/documentation/content-controls/require-membership-function/](https://www.paidmembershipspro.com/documentation/content-controls/require-membership-function/)
 * I hope this helps get you started.

Viewing 1 replies (of 1 total)

The topic ‘Conditional for restricted post’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paid-memberships-pro_f1dacb.svg)
 * [Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions](https://wordpress.org/plugins/paid-memberships-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paid-memberships-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paid-memberships-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/paid-memberships-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paid-memberships-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paid-memberships-pro/reviews/)

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [paidmembershipspro](https://wordpress.org/support/topic-tag/paidmembershipspro/)

 * 1 reply
 * 2 participants
 * Last reply from: [Andrew Lima](https://wordpress.org/support/users/andrewza/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/conditional-for-restricted-post/#post-13985240)
 * Status: resolved