Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active February 19, 2016 14:35
Show Gist options
  • Select an option

  • Save Pebblo/47ba0ea1f0367f760288 to your computer and use it in GitHub Desktop.

Select an option

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)
<?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);
@Pebblo
Copy link
Copy Markdown
Author

Pebblo commented Feb 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment