Skip to content

Instantly share code, notes, and snippets.

@leanneromak
Last active December 10, 2015 17:27
Show Gist options
  • Save leanneromak/3bfb72def46c7aa73ecc to your computer and use it in GitHub Desktop.
Save leanneromak/3bfb72def46c7aa73ecc to your computer and use it in GitHub Desktop.
Editor user role for functions.php
/**
* 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