PMPro Membership Level

Paid Memberships Pro (PMPro) is a WordPress plugin you to sell different membership levels to people. You can use Conditional Blocks to control the visibility of WordPress blocks based on the membership of the current user.


How to restrict content based on Membership level

Making exclusive content for specific memberships is easy when you combine Conditional Blocks & Paid Memberships Pro. You’ll be able to apply visibility condition to any WordPress blocks with a few clicks. All without writing a line of code!

1. Setup your memberships levels

The PMPro plugin takes you through the setting up your initial membership levels and pricing, therefore you just need to confirm the names of those levels. Navigate the Paid Memberships settings to see a list of all the levels.

Paid Memberships Pro level screen.

As you can see in the screenshot, our membership is called “premium” and it’s billed at $10 per month.

2. Create premium content with WordPress Blocks

Navigate into a page or post within WordPress where you’ll create the premium only content.

If you need to create multiple blocks of content, then we recommend that you nest the content within a Group Block. Group Blocks are easier to manage since you can apply visibility conditions to the whole group at once.

Screenshot showing example content in WordPress blocks

3. Adding visibility rules based on membership

It’s time to add the visibility rules, we want one of the blocks to display when the current user has the Premium membership, and the other block should display when they don’t have the membership.

  • Click on the block you’ve created
  • Navigate to the Conditional Blocks settings in the sidebar, then click on Edit Visibility.
  • Open the condition list and select the PMPro Membership Level condition.
  • You can now select which membership the should be able to see the content of the block.

All Paid Memberships Pro data is automatically pull into Conditional Blocks. You don’t need to configure anything.

Screenshot of selecting a membership level within the Conditional Blocks builder.

Membership levels & status options

In addition to selecting a specific membership level you’ve previously named, you can also choose the following:

  • No Membership: The current user doesn’t have a membership at all.
  • Any Membership: The current user has at least one membership.
  • Expired Membership: The current user had a membership, but the status is expired.

You may combine any of these to create even more targeted content. Combining conditions is done using the AND, OR logic within Condition sets.

Preview & you’re done!

It’s important to know that the conditions will always run for the current user who is logged in. Therefore we recommend that you setup multiple users with different memberships during testing. Plugins like User Switching are perfect for quickly changing between users while developing your site.

You can now go forward and create great membership sites with WordPress Blocks. Creativity is your friend since you apply these visibility conditions to any block, especially if you have WordPress Full Site Editing enabled.

With Full Site Editing you could create separate navigation menus, sidebars, logos etc for different membership statues. Recommend that you can combine the PMPro Membership Level with all our other conditions as well.

Custom integration with snippet (Old Method)

Paid Memberships Pro has a built-in function called pmpro_hasMembershipLevel. To use this function with the PHP Logic (Custom conditions) we’ll need to register it as an allowed function using the snippet below.

This guide was suggested by Hari via support.

Place the snippet in your theme’s function.php file, custom plugin, or you can use the (free) Code Snippets plugin

 * Show blocks depending on the current users memebership. This snippet registers pmpro_hasMembershipLevel to be used with Conditional Blocks PHP logic.
 * @param array $allowed_functions
 * @return array $allowed_functions
function custom_add_allowed_function_conditional_blocks( $allowed_functions ) {

	// Add Paid Membership Pro Level condition.
	array_push( $allowed_functions, 'pmpro_hasMembershipLevel' );

	return $allowed_functions;
add_filter( 'conditional_blocks_filter_php_logic_functions', 'custom_add_allowed_function_conditional_blocks', 10, 1 );

Code language: PHP (php)

Displaying WordPress blocks based on membership

Screenshot of displaying a WordPress block based on the users Paid Memberships Pro level.

Once you’ve placed the snippet on your site, you are ready to use it inside Conditional Blocks.

Create and select the WordPress blocks you wish to only be visible to specific membership levels, then add the PHP Logic condition.

Let’s say you want to display selected blocks to members who hold the ‘gold‘ membership. You’d simply write in the function name and use the allowed parameters (from the PMPRO docs).

Make the blocks visible to Gold Members

You’ll need to write the following pmpro_hasMembershipLevel('gold') and save.

Make the blocks visible to multiple memberships levels

Adding multiple lines to the same PHP logic condition will check if any of the called functions are TRUE.

pmpro_hasMembershipLevel('silver');Code language: PHP (php)

The selected block will be only visible to users who hold either a gold or silver membership.

TIP: If one user MUST have both membership levels at the same time, then you should add another PHP Logic condition. Both PHP logic conditions have to be true for the block to visible.

Make the blocks hidden to Gold Members

You’ll need to write the following !pmpro_hasMembershipLevel('gold') and save.

More information

We recommend reading the documentation for PHP Logic condition for more in-depth use and tips. We also have a write-up on Github for the Paid Memberships Pro integration.

Was this page helpful?