Additional menu

Get MemberPress today! Start getting paid for the content you create! Get MemberPress Now

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 Options plugin.

Step 2

Widget Options adds some restriction options to the bottom of every widget like this:

Step 3

Set up 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 Options. Widget Options only wants the part including current_user_can(). So for the screenshot below, you would copy ONLY the following part:

current_user_can('mepr-active','rules:1165')

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 click the little cogwheel in the list of settings for Widget Options. Click the
Logic tab, and paste your copied code from Step 3:

Note: Each Rule has its unique ID (1165 in the example above) so be sure that the ID is correct when you paste the partial content code into the Widget Options settings on your widgets.

Step 5

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

Was this article helpful?

Related Articles

computer girl

Get MemberPress today!

Start getting paid for the content you create.