Last active
February 19, 2016 14:35
-
-
Save Pebblo/47ba0ea1f0367f760288 to your computer and use it in GitHub Desktop.
A site specific plugin that can be used to remove the Extensions & Services menu items from both the Admin and the Admin bar for all users apart from those with the manage_options capability (usually this would be Administrators)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Event Espresso site specific functions | |
| Description: Add custom functions for Event Espresso to this plugin. | |
| /* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */ | |
| //Remove the Extensions & Services menu for all but admins with manage_options cap | |
| function tw_ee_remove_services_menu() { | |
| if( !current_user_can( 'manage_options' ) ) { | |
| remove_submenu_page( 'espresso_events', 'espresso_packages' ); | |
| } | |
| } | |
| add_action( 'admin_menu', 'tw_ee_remove_services_menu', 11 ); | |
| //Remove the Extensions & Services menu item from the Admin bar for all users bar admins with the manage_options cap | |
| function ee_test_cap_current_user_can_context_filters( $cap, $id ) { | |
| if ( $cap == 'ee_read_ee' ) { | |
| if( !current_user_can( 'manage_options') ) { | |
| return 'you_no_access'; | |
| } | |
| } | |
| return $cap; | |
| } | |
| add_filter( 'FHEE__EE_Capabilities__current_user_can__cap__ee_admin_bar_menu_espresso-toolbar-extensions-and-services', 'ee_test_cap_current_user_can_context_filters', 10, 2); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ref: http://developer.eventespresso.com/docs/ee-capability-system-overview/
Forum: https://eventespresso.com/topic/hide-extensions-and-services/