Allow Editors to protect posts and verify users

Can I give an editor on my WordPress site permission to edit and create restricted articles for membership 2?
My editor can create posts but cannot make them protected. I also would like to allow them to verify users.

  • Adam Czajczyk

    Hello HortiTrends

    I hope you're well today and thank you for your question!

    Currently, the Membership 2 Pro plugin only allows admin-role users to set enable/disable protection for posts/pages. Any other user that can edit content could use shortcodes to protect entire or part of the content by putting the post content between

    [ms-protect-content id="X"]

    and

    [/ms-protect-content]

    pair of shortcodes, where X is a numberical ID of a membership that should be used for protection.

    I realize that this is not the same as turning protection for entire post, though. I think changing that to allow other user-roles to enable/disable/manage protection would require changes in plugin's code but let's wait for our developers' feedback on that. Please keep an eye on this ticket and we'll let you know once we got a reply from them.

    As for "allowing to verify users". I must say I'm not sure what do you mean by "verify users". Could you please explain that a bit more?

    Best regards,
    Adam

  • Panos

    Hi there HortiTrends ,

    In order to allow editors to enable/disable protection you could try adding the following snippet in a mu-plugin:

    add_filter( 'ms_model_member_is_admin_user', function( $is_admin, $user_id, $capability ){
    
    	global $pagenow;
    
    	if( 'post.php' == $pagenow && 'edit' == $_GET[ 'action' ] ){
    		$is_admin = user_can( $user_id, 'edit_others_posts' );
    	}
    
    	return $is_admin;
    }, 20, 3);

    In case you are not familiar with mu-plugins you could read about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Hope this helps!
    Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.