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
- Navigate to Memberships > Settings > Advanced > Other Settings.
- Change the “Hide Ads from Non-Members” setting to “Hide Ads From All Members” or “Hide Ads From Certain Members“.
- 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

Get Support From Our Team of Experts
For more help with this PMPro feature, check out our Support Page with three ways to get support as a free or premium member.
Last updated on June 25, 2024