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 menu items is done with the assistance of the Menu Item Visibility Control plugin.
Once activated, Menu Item Visibility Control will add an extra input field to each menu item, as shown below:
The visibility input field allows you to enter PHP conditional tags and the menu item will only be displayed if the conditional tags validate as TRUE.
If you want to only show a menu item to active membership holders (regardless of their membership level), enter this in the input field:
If you wish to show a menu item only to people without an active membership, then 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 whitescreen.
If you want your menu items to always be visible to site admins then you'll need to append
|| current_user_can( 'manage_options' ) to your visibility conditions. Example:
in_array( 2, rcp_get_customer_membership_level_ids() ) || current_user_can( 'manage_options' )