Quantcast
Channel: Code Recipe Posts for Extending Your Membership Site
Viewing all articles
Browse latest Browse all 326

Hide Widgets for Members Only

$
0
0

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.

Viewing all articles
Browse latest Browse all 326

Trending Articles