If you use ads as a way to monetize your site, you can optionally wrap the ad block with a built-in PHP function in order to hide or customize those ads to site members. This can be a unique value offering for users interested in having an ad-free or more ad-targeted experience on your site.

The pmpro_displayAds() Function

  1. Navigate to Memberships > Settings > Advanced > Other Settings.
  2. Change the “Hide Ads from Non-Members” setting to “Hide Ads From All Members” or “Hide Ads From Certain Members“.
  3. Save Settings.

Use the function below to wrap and insert ad blocks that will load based on how you have configured the admin setting.

if ( function_exists( 'pmpro_displayAds' ) && pmpro_displayAds() ) {
	//insert ad code here
}

Other Methods to Hide Ads

In addition to this core plugin function, you can also consider using the [membership] shortcode, pmpro_hasMembershipLevel function, or a third-party ad management plugin that offers PMPro support. Read this companion article to explore all of the possible methods for controlling ads by level.

Settings Page Screenshot

Screenshot of Other Advanced Settings with Hide Ads Setting set to Hide Ads from Certain Members
The “Hide Ads” section on the Memberships > Settings > Advanced page in the WordPress Admin.
Was this article helpful?
YesNo