[Support request] Remove WPSP For Non Admin Uses

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Remove WPSP For Non Admin Uses

This topic contains 5 replies, has 2 voices, and was last updated by  Tom 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7715

    Jake
    Participant

    Hi Tom,

    Is there a way to disable WPSP for non-admin users?

    Even when using a permissions plugin like: https://wordpress.org/plugins/capability-manager-enhanced/ I can’t see an easy way to disable WPSP for certain permission levels.

    Any ideas?

    Thank you for your help 🙂

    #7746

    Tom
    Keymaster

    Hi there,

    Give this a shot:

    add_filter( 'register_post_type_args', function( $args, $post_type ) {
        if ( 'wp_show_posts' !== $post_type ) {
            return $args;
         }
    
        $args['capability_type'] = 'manage_options';
    
        return $args;
    }, 10, 2 );

    Adding PHP: https://docs.wpshowposts.com/article/adding-php/

    Let me know 🙂

    #7754

    Jake
    Participant

    Hey Tom,

    I added the code above and can confirm that WPSP is no longer showing for “Authors”.

    How exactly is this code working? When will WPSP show/not show – is it only set to show when “Posts” are allowed?

    Thanks for the code, and thank you for clarifying 🙂

    #7771

    Tom
    Keymaster

    That code makes it so only users with the manage_options capability (admins) can see the admin area for Show Posts.

    Every user role has capabilities, with manage_options being one of the ones for admins.

    #7779

    Jake
    Participant

    Arrr that makes sense.

    So I could hence enable access to WPSP for say… Editors – by enabling this option https://imgur.com/a/CbmMcLk

    Thank you for the code + explanation Tom! 🙂

    #7789

    Tom
    Keymaster

    You can change manage_options to any one of these: https://codex.wordpress.org/Roles_and_Capabilities

    No problem! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.