How To Add And Remove Capacity of WordPress User

function add_theme_caps() {
    $role = get_role( 'manager' );

    // This only works, because it accesses the class instance.
    // would allow the author to edit others' posts for current theme only
    $role->add_cap( 'upload_files' );
    $role->add_cap( 'edit_dashboard' );
    $role->add_cap( 'switch_themes' );
    $role->add_cap( 'edit_theme_options' ); 
    $role->add_cap( 'edit_themes' );
    $role->add_cap( 'install_themes' );
    $role->add_cap( 'edit_plugins' );
    $role->add_cap( 'activate_plugins' );
    $role->add_cap( 'install_plugins' );
    $role->add_cap( 'remove_users' );
    $role->add_cap( 'add_users' );
    $role->add_cap( 'activate_plugins' );
    $role->add_cap( 'customize' );
    $role->add_cap( 'manage_options' );
    $role->add_cap( 'manage_categories' );
    $role->add_cap( 'manage_links' );
    $role->add_cap( 'import' );
    $role->add_cap( 'edit_pages' );
    $role->add_cap( 'promote_users' );
    $role->add_cap( 'edit_others_posts' );
    $role->add_cap( 'publish_posts' );


$role1 = get_role( 'client' );

    // This only works, because it accesses the class instance.
    // would allow the author to edit others' posts for current theme only
    $role1->add_cap( 'upload_files' );
    $role1->add_cap( 'edit_dashboard' );
    $role1->add_cap( 'switch_themes' );
    $role1->add_cap( 'edit_theme_options' ); 
    $role1->add_cap( 'edit_themes' );
    $role1->add_cap( 'install_themes' );
    $role1->add_cap( 'edit_plugins' );
    $role1->add_cap( 'activate_plugins' );
    $role1->add_cap( 'install_plugins' );
    $role1->add_cap( 'remove_users' );
    $role1->add_cap( 'add_users' );
    $role1->add_cap( 'activate_plugins' );
    $role1->add_cap( 'customize' );
    $role1->add_cap( 'manage_options' );
    $role1->add_cap( 'manage_categories' );
    $role1->add_cap( 'manage_links' );
    $role1->add_cap( 'import' );
    $role1->add_cap( 'edit_pages' );
    $role1->add_cap( 'promote_users' );
$role1->remove_cap( 'publish_posts' );
    $role1->add_cap( 'edit_posts' );
    $role1->remove_cap( 'edit_others_posts' );
    $role1->add_cap( 'read_private_posts' );
    $role1->add_cap( 'delete_posts' );
    $role1->remove_cap( 'delete_private_posts' );
    $role1->add_cap( 'read_post' );
    $role1->remove_cap( 'delete_others_posts' );
    $role1->remove_cap( 'edit_published_posts' );
    $role1->remove_cap( 'delete_published_posts' );
    $role1->add_cap( 'delete_users' );

}
add_action( 'admin_init', 'add_theme_caps');

Comments

Popular posts from this blog

How To Remove and Add Visit Site Menu From WordPress Admin Bar?

wp login page