Site logo

[Resolved] Remove WPSP from Dashboard Menu by User Role

Home Forums Support [Resolved] Remove WPSP from Dashboard Menu by User Role

Home Forums Support Remove WPSP from Dashboard Menu by User Role

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1242136
    Paul

    I want to remove the WP Show Posts menu item from the left-hand menu in the WP dashboard for certain user roles only, such as Editor. How can I do that? I tried the User Role Editor plugin, but the WPSP post permissions are mixed in with other CPTs post permissions (such as Strong Testimonials and GP Elements and Elementor Templates) and so I need another work-around to just remove WPSP for Editors from the menu altogether. Thanks in advance.

    WPSP in Dashboard Menu

    #1242245
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You could try this:

    add_action( 'admin_menu', function() {
        if ( ! current_user_can( 'manage_options' ) ) {
            remove_menu_page( 'edit.php?post_type=wp_show_posts' );
        }
    }, 500 );

    Let me know 🙂

    #1242285
    Paul

    Nope, didn’t work unfortunately. 🙁 (UPDATE: Your revised code above works Tom, thanks!!!)

    #1243228
    Tom
    Lead Developer
    Lead Developer
    #1243293
    Paul

    That did work. And how can I modify it to also exclude the (Elementor) Templates menu item from the left Dashboard menu? Basically I need to exclude both WPSP and Templates from the menu as both affect the design of the site which Editors shouldn’t be messing with.

    #1243606
    Tom
    Lead Developer
    Lead Developer

    You would duplicate this line: remove_menu_page( 'edit.php?post_type=wp_show_posts' );

    But change wp_show_posts to whatever their slug is in the URL.

    #1243637
    Paul

    Hey, that did the trick!

    Here’s the code I used:

    add_action( 'admin_menu', function() {
        if ( ! current_user_can( 'manage_options' ) ) {
            remove_menu_page( 'edit.php?post_type=wp_show_posts' );
    		remove_menu_page( 'edit.php?post_type=elementor_library' );
        }
    }, 500 );

    Thanks so much Tom!

    #1244447
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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