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.

Any method to hide permalink page created by plugins? Theses pages cannot be edited to restrict access by levels so maybe it’s possible with a script?

Plugins create pages in different ways. Which plugin is it? Which page?

We have scripts and posts on the blog here RE locking down CPT pages, redirecting away from member pages, and locking down URLs. One of these might be appropriate for you.

It’s WP Store Locator. The plugin’s shortcode page is locked but not all pages created by it. So people can access theses pages if the URL is shared by somebody.

Adding this broke my site. I added it in just as you had. Here is my page:

<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/

ID)) {
if(in_array($args[‘id’], $hide_sidebars_array) )
return false;
else
return $instance;
}
}
add_filter(‘widget_display_callback’,’my_pmpro_widget_display_callback’, 10, 3);

Leave a Reply

Your email address will not be published. Required fields are marked *