Created
February 2, 2017 12:43
-
-
Save michaelwilhelmsen/0e4e0c74d208b5b727a8a51daa7f8a0c to your computer and use it in GitHub Desktop.
Allow additional Editor capabilities in Wordpress admin.
Allow editors to manage Widgets and Menus.
Allow editors to manage Users below Editor level.
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
| /************* EDITOR ACCESS *****************/ | |
| // Allow editors to manage Widgets and Menus | |
| function sp_editor_capabilities() { | |
| $editor = get_role( 'editor' ); | |
| if (!$editor->has_cap( 'edit_theme_options' ) ) { | |
| $editor->add_cap( 'edit_theme_options' ); | |
| } | |
| if (!$editor->has_cap( 'wpml_manage_string_translation' ) ) { | |
| $editor->add_cap( 'wpml_manage_string_translation' ); | |
| } | |
| if (!$editor->has_cap( 'wpml_manage_taxonomy_translation' ) ) { | |
| $editor->add_cap( 'wpml_manage_taxonomy_translation' ); | |
| } | |
| } | |
| add_action('admin_head', 'sp_editor_capabilities'); | |
| // Allow editors to manage Users below Editor level | |
| function sp_hide_menu() { | |
| $user = new WP_User(get_current_user_id()); | |
| if (!empty( $user->roles) && is_array($user->roles)) { | |
| foreach ($user->roles as $role) | |
| $role = $role; | |
| } | |
| if($role == "editor") { | |
| remove_menu_page( 'tools.php' ); | |
| remove_submenu_page( 'themes.php', 'themes.php' ); | |
| remove_submenu_page( 'themes.php', 'customize.php' ); | |
| global $submenu; | |
| unset($submenu['themes.php'][6]); | |
| } | |
| } | |
| add_action('admin_head', 'sp_hide_menu'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment