Site logo

[Support request] Hide Generatepress Options for editors in backend

Home Forums Support [Support request] Hide Generatepress Options for editors in backend

Home Forums Support Hide Generatepress Options for editors in backend

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2525712
    Stefan

    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]);
    });
    #2525791
    David
    Staff
    Customer Support
    #2551672
    Jason

    Hi Stefan,

    I happened to be working on the same thing last week. Here’s what you need:

    
    // Hide GeneratePress page
    remove_submenu_page( 'themes.php', 'generate-options' );
    

    I hope this helps!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.