Last active
December 10, 2015 17:27
-
-
Save leanneromak/3bfb72def46c7aa73ecc to your computer and use it in GitHub Desktop.
Editor user role for functions.php
This file contains 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
/** | |
* control editor role | |
*/ | |
$role = get_role('editor'); | |
$role->add_cap('edit_theme_options'); | |
function custom_admin_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_submenu_page( 'themes.php', 'customize.php'); | |
remove_menu_page( 'edit-comments.php' ); | |
remove_submenu_page( 'themes.php', 'themes.php' ); | |
remove_submenu_page( 'themes.php', 'widgets.php' ); | |
remove_menu_page( 'customize.php' ); | |
remove_menu_page( 'options-general.php' ); | |
remove_submenu_page( 'home-page-header' ); | |
remove_menu_page( 'admin.php?page=current-theme' ); | |
} | |
} | |
add_action('admin_menu', 'custom_admin_menu'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment