Yes, you can!
Warning: This article references functions that were introduced in RCP version 3.0.5. You must be on RCP version 3.0.5 or higher in order to use the functions named in this tutorial.
Restricting widgets 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. Clicking on the gear icon then the "Logic" sub-tab will present you with a text area 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 membership holders (regardless of their membership level), enter the code below in the input field.
Now the widget will be completely hidden unless the current user has an active membership.
If you wish to show a widget only to people without an active membership you can use:
The ! means "not".
If you wish to show a menu item to customers with an active membership that is paid, then use this code:
If you wish to show a menu item to customers with an active membership that is free, then use this code:
If you wish to show a menu item only to active members of a specific membership level (level ID #2), then use:
in_array( 2, rcp_get_customer_membership_level_ids() )
Here's the same but with membership level names instead of IDs:
in_array( 'Gold', rcp_get_customer_membership_level_names() )
You can also show a menu item to active members who are on levels #1 or #2
count( array_intersect( rcp_get_customer_membership_level_ids(), array( 1, 2 ) ) )
You can check for additional membership levels by adding more IDs to the array. For example, here's how you'd check for IDs 1, 2, and 4:
count( array_intersect( rcp_get_customer_membership_level_ids(), array( 1, 2, 4 ) ) )
Here's the same, but using membership level names Bronze, Silver, and Gold:
count( array_intersect( rcp_get_customer_membership_level_names(), array( 'Bronze', 'Silver', 'Gold' ) ) )
If you want to show a menu item to all expired members, perhaps to encourage them to signup again, use:
You must be very careful when entering the visibility options. A mistake could result in a white screen.