Table of Contents
This is useful when you might want to give access to specific PMS pages to other users from your website, but you don’t want them to access your whole Dashboard.
In order to achieve this, 2 things are necessary:
* add this custom capability to their user role: pms_edit_capability
* add the same custom capability to your Administrator account
To give access to the Payments and Members pages you need to use the following code:
1 2 3 4 5 6 7 | add_filter( 'pms_submenu_page_capability', 'pmsc_allow_editors_to_view_pages', 20, 2 ); function pmsc_allow_editors_to_view_pages( $capability, $menu_slug ){ if( in_array( $menu_slug, array( 'paid-member-subscriptions', 'pms-payments-page', 'pms-members-page' ) ) ) return 'pms_edit_capability'; return $capability; } |
The above code can be modified in order to target other plugin pages as well:
In the code, replace the existing entries or add another comma-separated entry in quotes, e.g.: array( ‘pms-payments-page’, ‘pms-members-page’, ‘pms-reports-page’ )
To give access to the Subscription Plans and Discount Codes pages, use the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | add_filter( 'pms_custom_post_type_capability', 'pmsc_allow_editors_to_view_cpts', 20, 2 ); function pmsc_allow_editors_to_view_cpts( $capability, $menu_slug ){ $target_pages = array( 'pms-subscription', // subscription plans 'pms-discount-codes', // discount codes ); if( in_array( $menu_slug, $target_pages ) ) return 'pms_edit_capability'; return $capability; } |
If you’ve given access to a user role to view the Reports -> Export page, then in order for the “Generate CSV” functionality to actually work you will also need to add the following code:
1 2 3 4 | add_filter( 'pms_export_capability', 'pmsc_change_export_capability' ); function pmsc_change_export_capability(){ return 'pms_edit_capability'; } |
Accept (recurring) payments, create subscription plans and restrict content on your website. Easily setup a WordPress membership site using Paid Member Subscriptions.
Get Paid Member SubscriptionsCombine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.
Get 25% off with the bundle