Hide Widgets for Members Only

If you’re using widgets on your WordPress site and want to customize them for members and non-members, check out the recipes below. We’ll provide a way to filter an entire widget area for members-only, as well as a recipe to hide a specific widget instance based on the current user’s membership level.


Hide an Entire Widget Area

The following recipe allows you to define dynamic sidebars (by sidebar ID) to hide or show based on the membership requirements of the active post ID. Any widgets placed in the filtered widget areas will not show if the current user does not have access to the post ID.

This code recipe requires a Plus Account or higher.

View Membership Options

To discover the sidebar ID, you can look in your theme files to locate where the dynamic_sidebar is displayed.

Hide a Specific Widget Instance

The following recipe allows you to hide specific widget instances (regardless of the widget area they are placed in) based on the current user’s membership level. This code recipe can be extended for several membership level checks based on your needs.

This code recipe requires a Plus Account or higher.

View Membership Options

To discover the widget instance’s ID, you can use your browser’s Web Inspect features. The ID will be in a format widgettype-NUM, for example text-2 or recent-comments-1.

Restrict the display of Advanced Custom Fields (ACF) fields by Membership Level

Advanced Custom Fields PluginAdvanced Custom Fields is a popular plugin available in the WordPress.org Plugin Repository. The plugin allows you to add structured information to your posts, pages, and more.

This guide explains three primary methods to hide or show fields based on the membership requirements for the post.


Option 1: The pmpro_hasMembershipLevel() function.

Since the ACF plugin requires you to add custom PHP functions to your theme’s template files, one of the easiest ways to restrict the display of fields is to wrap your entire display in the pmpro_hasMembershipLevel() function. Here’s an example of using the function in your template files:

You can read full documentation on the pmpro_hasMembershipLevel() function here.


Option 2: The pmpro_has_membership_access() function.

Similar to the option above, this method will look to the post’s required membership levels. You won’t need to specify the level IDs when using this function, it will inherit the membership protection from the “Require Membership” metabox for that post. Here’s an example of using the function in your template files:


Option 3: The acf/format_value Filter

If you’re using version 5+ of the Advanced Custom Fields plugin, you can write a single function that will filter all fields on a member-protected page. This code will uses the acf/format_value filter to check first if the user has access to the post and will then optionally restrict the display of the field.

Note that this will not restrict the display of any custom HTML you have in your page templates, but it is a simple solution that won’t require editing all of your theme files.


If you need help altering these recipes to suit your needs, feel free to get in touch with one of our Support Engineers on our Member Support Forum.

Add a customized notification banner to alert your members of upcoming expiration.

This code recipe adds a notification banner to remind members that their account will expire within 7 days—or any custom timeframe you would like. You can use the recipes with any WordPress theme, or specifically with a membership site using Memberlite.


About the Code Recipe

By default, Paid Memberships Pro will send members an expiration email notice 7 days prior to their expiration date (by the way, if you want to add more email expiration warnings, see our Extra Expiration Warning Emails Add On).

This recipe adds an expiration warning directly on your site, reminding the logged in member that they must renew to maintain access. The banner will only be shown to a member that has an active membership level with an expiration date within the next 7 days. You won’t need to rely on email delivery, receipt, or that your member will actually read the message.

If a member decides to renew their membership by clicking the “Click here to renew membership” link, they will be redirected to the membership levels page. From here they can select their desired membership level and proceed to checkout. They will no longer see the message


This code recipe requires a Plus Account or higher.

View Membership Options

Offer members a discounted rate for upgrading to a higher level

Encourage existing members to upgrade to a higher priced level by offering a discount that is unique to them – no discount code required.


About the Recipe

This code recipe was recently developed for one of our Plus Members.  The member was in the process of launching a new membership level and wanted to encourage their current members to make the upgrade to the new membership level by offering a unique discount that can only be seen or used by the current members of their site. The current members would not need to use a discount code to apply for the deal. All they would need to do is select the new membership level and confirm their subscription by checking out of the site.

For those who are looking to simply offer upgrading members the chance to pay the difference between their current and new level, have a look at our Proration Add-On.

Note: This code recipe will not change the amount that is seen on the Membership Level Page of your site and the discounted price will only be seen once on the checkout page. Make sure to communicate this effectively to your members to avoid confusion.

Code Recipe


This code recipe requires a Plus Account or higher.

View Membership Options

Show a Member’s Level Name in Post Comments

When a member posts a comment on your site, the recipe below will display their Membership Level name following the comment author’s name.

This can be useful for many membership sites, specifically sites that have multiple tiers of membership which equate to a member’s status, skill-level or denote a relationship to your company.

The author name is also updated in the Comments section of the admin dashboard so you can tell what membership levels users have when approving pending comments. This has been particularly useful for us on our own site to tell which of our blog post commenters are paying members.

Show member level name next to author name in comment

This page requires a PMPro Core Account or higher.

Already have an account? Login Now »

New to this site? Register Now »

Require Membership to Purchase Specific Categories of Products in WooCommerce

Offer special “members-only” products that require the user to have an active membership in order to purchase. The selected products will still appear in your Shop page, but cannot be purchased by non-members.


About the Recipe

This customization recipe allows you to restrict the purchase of products in designated WooCommerce product categories for active members only. You now have full control over which categories require a membership in order to be purchased and which product categories (if any) are available to the public, regardless of their membership status.

This recipe can be used on its own or in conjunction with our WooCommerce Integration Add On, which offers additional features for integrating Paid Memberships Pro with WooCommerce.

Woocommerce product example


Some suggested use cases include:

  1. A shop that offers an array of products, some of which will only relate to members. This can include products like Membership-branded clothing or accessories, access to digital add-on products, specialized meal or diet plans and more. Basically, anything that you only want your members to be able to own and purchase.
  2. A shop that offers unique or special products that can entice users to sign up for a membership in order to purchase. This can be an added incentive to users thinking about signing up for your membership.
PRO TIP: Try to make your membership level/products as easy to sign up for and purchase as possible. A user may feel reluctant to join a membership only to be able to purchase a particular product. This can leave them feeling “forced” into something that they do not want to be a part of.Look at offering a lot of value for your membership packages and rather use this as an “added benefit” instead of a means to purchase a product.


The Code Recipe

This code recipe requires a Plus Account or higher.

View Membership Options

Make the Most of Your Ad Space with Level Specific Ads Targeting

Advertisements are a classic method of monetizing your website, and ad-serving networks such as Google Adsense make it fast and easy to start displaying ads.

It’s important for a membership site to consider which ads to display for non-members, per-level or completely hidden to members for an “ad-free” experience. Read on to explore how to control ads for your PMPro-powered membership site.


Considering Ads for a Membership Site

Your site’s membership is often the most lucrative product sold through your website. That said, ads can still be a component of your revenue stream if you make smart choices about ad placement for free members and site visitors.

With the methods outlined below, you can target which ads display to which users. This unlocks a unique opportunity to target your ads for each membership level, not only to hide ads for members, but to show premium ads with exclusive partner offers to your paid members.


Ad Networks, Affiliate Ads, and Direct Ad Sales

The simplest way to insert ads is via an ad network. These services connect advertisers with sites that want to make money by displaying ads. You’ll be provided with a script or other integration method to dynamically embed third-party ads on your site. Some popular ad networks that you may be familiar with include Google Adsense, Facebook Audience Network, and Amazon a9.

Alternatives to an ad network include affiliate networks or direct ad sales. For this case, you would be obtain ads (graphics, links and promos) directly through company’s affiliate program or via a service such as ShareASale or CJ Affiliate. These methods take a bit more time to set up and manage, but generally offer a higher commission than an ad network.

Option 1: The pmpro_displayAds() Function

This PHP function checks against the “Hide Ads from Non-Members” settings under Memberships > Advanced Settings. It allows you to wrap and insert ad blocks that will load based on how you have configured the admin setting.

if(pmpro_displayAds())
{
//insert ad code here
}

Option 2: The [membership] Shortcode

If you are inserting ad blocks into posts or pages, you can simply use the shortcode to wrap your inserted content. Using this method, the ads will only be shown to the specified visitors or members.

View Shortcode Documentation

Option 3: The pmpro_hasMembershipLevel() Function

This PHP function allows you to check whether a user has any membership level or a specific membership level. You can then insert your ad blocks wrapped in the appropriate conditional check to achieve the desired result.

View Function Documentation

Option 4: Using Advanced Ads Pro

Advanced Ads Pro has just released a native integration for Paid Membership Pro. You can now target ads on your membership site in relation to the membership level of your visitors.

View Premium Plugin

Option 5: Integrating with Other Ads Plugins for WordPress

Many ads plugins for WordPress make use of shortcodes to allow you to insert the “ad block” into your content, then manage the content of the ad in a central place. In most cases you can use these shortcodes in combination with the shortcode method outlined above.

Alternately, I have seen ads plugins that offer ads widgets. You can use these plugins in combination with the hide widgets for members recipe outlined in this post.

Lastly, if your ads plugin automatically inserts ads on pages or posts, please post a topic on our support forum (Plus or Unlimited membership required) and we can help you locate available filters in your plugin to conditionally display ads based on membership status.

Allow Members to Favorite Posts using the Favorites Plugin for WordPress

Add a special feature for your members that allows them to mark posts as “Favorites”. Then, show your members their bookmarked posts on the Membership Account page. Below are two code recipes that integrate Paid Memberships Pro with Favorites by Kyle Phillips.

This page requires a PMPro Core Account or higher.

Already have an account? Login Now »

New to this site? Register Now »

Lock Your Entire eCommerce Shop for Members-Only

The code recipes below demonstrate how to restrict your online store to members-only using WooCommerce or Jigoshop. If you’re using a different eCommerce plugin, post a topic in our member forums and we will help you get the restriction in place.

This page requires a PMPro Core Account or higher.

Already have an account? Login Now »

New to this site? Register Now »

Add Links by Membership Level to the Membership Account Page “links” Section

As part of our ongoing Hooks and Filters documentation updates, I wanted to post a quick recipe for how to add links to the Membership Account page under the “Member Links” section.


Available Hooks for the Member Links Section

You can use these filters in combination with the pmpro_hasMembershipLevel() function to check a user’s level before displaying links.


The Code Recipe

This code recipe requires a PMPro Plus Account or higher.

View Membership Options