Can I hide widgets from non-members?
Yes you can!
Restricting widgets just requires a third party plugin that allows you to control widget visibility via PHP code. One example is the Widget Options plugin.
Once activated, a new settings section will appear at the bottom of each widget.
There are several different tabs. You want to click on the gear icon, and then the "Logic" sub-tab. This will present you with a textarea field that will allow you to enter PHP code to determine who gets to view the widget. The widget will only appear if the code in that box validates as TRUE.
If you want to only show a menu item to paid (and active) subscription holders (regardless of their subscription level), enter this in the input field:
Now the widget will be completely hidden unless the current user has an active paid subscription.
If you wish to show a widget only to non-active members, then use:
The ! means "not".
If you wish to show a widget only to active members of a specific subscription level, then use:
rcp_is_active() && rcp_get_subscription() == 'Gold'
Or by subscription ID:
rcp_is_active() && rcp_get_subscription_id() == 2
You can also show a widget to active members who are on levels "Gold" or "Silver":
rcp_is_active() && in_array( rcp_get_subscription(), array( 'Gold', 'Silver' ) )
You can check for additional subscription levels by adding more names to the list. For example:
rcp_is_active() && in_array( rcp_get_subscription(), array( 'Gold', 'Silver', 'Bronze' ) )
Here's the same but using IDs instead:
rcp_is_active() && in_array( rcp_get_subscription_id(), array( 2, 3 ) )
If you want to show a widget to all expired members, perhaps to encourage them to signup again, use:
You must be very careful when entering the logic code. A mistake could result in a whitescreen.