Hey dear team,
I have a little backend question that maybe you can help with.
I want to give editors access to the menu in the backend. For this I use the code below.
This all works fine. The only thing that is still showing is the options for Generatepress. The “elements” are hidden.
I have added the path for the generate-options. Unfortunately without success. Do you have another idea?
add_action('admin_menu', function() {
$user = wp_get_current_user();
// Check if the current user is an Editor - or bail
if(!in_array( 'editor', (array) $user->roles )) return;
// They're an editor, so grant the edit_theme_options capability if they don't have it
if ( !current_user_can( 'edit_theme_options' ) ) {
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
}
// Hide the Themes page
remove_submenu_page( 'themes.php', 'themes.php' );
// Hide the Widgets page
remove_submenu_page( 'themes.php', 'widgets.php' );
// Hide the Customize page
remove_submenu_page( 'themes.php', 'customize.php' );
// Hide the GP page
remove_submenu_page( 'themes.php', 'themes.php?page=generate-options' );
// Remove Customize from the Appearance submenu
global $submenu;
unset($submenu['themes.php'][6]);
});