Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Joost de Valk

    (@joostdevalk)

    No, although it will be possible to remove the advanced tab in an upcoming version.

    I had this need when using WordPress SEO in conjunction with Revisionary. Revisionary allows moderation of user-submitted corrections, but unfortunately didn’t allow moderation of the titles and descriptions set in WordPress SEO. This allowed any user with a “Revisor” role to alter the title or description of the page, unmoderated.

    I added the following code to my theme’s functions.php to remove the admin bar and meta boxes (that alter WordPress SEO settings for a post/page) for all Revisor users:

    function wpu_check_role( $role_to_check ){
    	//check to make sure pluggable.php and user.php have been loaded at this point
    	if (function_exists( 'is_user_logged_in' ) && function_exists( 'get_current_user_id' ) ) {
    			//check that user is logged in
    		if ( is_user_logged_in() ) {
    			//load user from logged-in user id
    			$user_ID = get_current_user_id();
    			$user = new WP_User( $user_ID );
    			//not sure why there would be more than one role, but let's iterate through it just in case there's a reason
    			if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    				foreach ( $user->roles as $role ) {
    					//return true if we have a match
    					if( $role == $role_to_check ) {
    						return true;
    					}
    				}
    			}
    		}
    	}
    	//no match found
    	return false;
    }
    
    if( wpu_check_role( 'revisor' ) ) {
    	//remove the seo forms when editing posts
    	remove_all_actions( 'add_meta_boxes' );
    	//remove the seo admin bar item (which just gave an access error when clicked)
    	remove_all_actions( 'admin_bar_menu' );
    }

    Hope this helps others in a similar situation.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Remove seo for roles lower then administrator’ is closed to new replies.