Viewing 2 replies - 1 through 2 (of 2 total)
  • That would be the best option yes. Use get_role(‘admin’) and remove_cap(..) to delete all capabilities the editor doesn’t have. I don’t have a clue why you would want to do so. You might be better of to create a new role and attach the right capabilities.

    Thread Starter Travis

    (@tjtaylor)

    Thanks! Ended up using this code:

    if ( !WP_LOCAL_DEV ) {
    	function git_production_set_capabilities() {
    
    	    // Get the role object.
    	    $administrator = get_role( 'administrator' );
    
    		// A list of capabilities to remove from administrators.
    	    $caps = array(
    	        'activate_plugins',
    	        'delete_plugins',
    	        'delete_themes',
    	        'edit_files',
    	        'edit_plugins',
    	        'edit_themes',
    	        'install_plugins',
    	        'install_themes',
    	        'update_core',
    	        'update_plugins',
    	        'update_themes'
    	    );
    
    	    foreach ( $caps as $cap ) {
    
    	        // Remove the capability.
    	        $administrator->remove_cap( $cap );
    	    }
    	}
    
    	add_action( 'init', 'git_production_set_capabilities' );
    }

    I’m doing this so I don’t accidentally update a plugin on the live site as it should only be done on production and then pushed to live.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Make admin have only editor features’ is closed to new replies.