Site logo

[Support request] Hide GeneratePress’ customizer option by role

Home Forums Support [Support request] Hide GeneratePress’ customizer option by role

Home Forums Support Hide GeneratePress’ customizer option by role

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1350149
    gregoirenoyelle

    Hi !
    Is-there a way to hide some GeneratePress’s customizer options for a specific role?
    I know how to use the current_user_can condition. I don’t want to use a plugin for that.
    I find this link: Remove all GP Customizer options. Is there the all list here?
    Thanks 🙂

    #1350842
    Tom
    Lead Developer
    Lead Developer

    That function is likely your best bet, although it is subject to change (if we re-organize etc..), so keep an eye on it.

    Let me know if you run into any issues 🙂

    #1350857
    gregoirenoyelle

    Hi Tom,
    OK thanks. I will test and I will add an example for the others.

    #1351061
    Tom
    Lead Developer
    Lead Developer

    Thanks!

    #1612619
    Ismael

    @gregoirenoyelle, ever got your code to work? I’m currently searching for the same thing.

    Show and hide customizer Panels, sections and settings based on user role.

    Thanks

    #1612646
    Ismael

    I just figured out, Thanks.

    #1613906
    gregoirenoyelle

    Ok @Ismael . Great

    #1754041
    Omar

    I ran into this ticket as I was trying to give my editor user the ability to add menus, without having access to the full “Appearance”. I found the below code, and have managed to hide everything I need to hide except for the Generate Options Page.

    /* Give Editor Appearance Edit Privilege */
    
    function add_theme_caps() {
        $role_object = get_role( 'editor' );
        $role_object->add_cap( 'edit_theme_options' );
    }
    add_action( 'admin_init', 'add_theme_caps');
    
    /* Hide Appearance Submenus Except Menu Page */
    
    function hide_menu() {
    
        if (current_user_can('editor')) {
    
            remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
            remove_submenu_page( 'themes.php', 'themes.php?page=generate-options' ); // hide theme options
            remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
            remove_submenu_page( 'themes.php', 'customize.php' ); // hide the customizer submenu        
            remove_submenu_page( 'themes.php', 'customize.php?return=%2Fwp-admin%2F' ); // hide the customizer submenu
    
        }
    }
    
    add_action('admin_head', 'hide_menu');
    

    This line below isn’t doing the trick and I would like to know if there is a way to resolve that.

            remove_submenu_page( 'themes.php', 'themes.php?page=generate-options' ); // hide theme options
    

    Thanks!

    #1754634
    Elvin
    Staff
    Customer Support
    #1761775
    Omar

    That very was helpful, Thanks!

    #1762739
    Elvin
    Staff
    Customer Support

    No problem. 🙂

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