Protecting Widgets

If you want to show/hide certain widgets depending on what the currently logged in member has purchased, then follow the steps below.

Step 1

Download and install the Widget Logic plugin.

Step 2

Widget Logic adds a new field to the bottom of every widget like this:

Step 3

Setup a Rule for the widget and set the Rule type to "Partial" - then click on the "Partial Content Codes" link to display the PHP snippet you'll need to use for Widget Logic. Widget Logic only wants the part including current_user_can(). So for the screenshot below you would copy ONLY current_user_can('mepr-active','rules:1839')

NOTE: if you don't want to create a rule, you can use current_user_can('mepr-active','membership:123') in step 4, where 123 is the unique membership id. If you would like to learn more about how to do this click here.

Step 4

Find the widget(s) you want to hide from unauthorized members, and paste the code you copied in step 3, into the Widget Logic box for this widget:

Note: Each Rule has it's own unique ID (1839 in the example above) so be sure that the ID is correct when you paste the partial content code into the Widget Logic settings on your widgets.

Step 5

Save the widget. It will now be hidden from members who do not have access.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.