Wordpress multisite, allow non super admins to create sites
-
01-10-2020 - |
문제
I'm creating a wordpress multisite for at costumer to uses with his own customers. He need to be able to create a site when he get a new customer, and his customer should be able to control the the site.
So I want me as an superadmin, and my customer's customers to be the admin the site, so what I need is a role in between a light version of the superadmin.
I can't figure this out, i have tried different plugins fx: "User Role Editor", but no luck so fare.
Someone now how to make this work?
해결책 2
So I finally found the solution. If installed the: "Extended Super Admins" plugin.
And then I the user the Super Admin role, and used the plugin to add a custom role based on the super admin and then it is just check the boxed of the rights he DON'T need to have.
It was really that simple!
다른 팁
In multisite installation there already is a default admin and super-admin role, and if standard capabilities are different than what you want you can modify them:
A default set of capabilities is pre-assigned to each role, but other capabilites can be assigned or removed using the
add_cap()
andremove_cap()
functions. New roles can be introduced or removed using theadd_role()
andremove_role()
functions.
In this way you can customize user capabilities to your needs;
As asked from toscho I'll make an example:
you can specify new role and caps with add_role()
(in ex. maior-admin
)
add_action('after_setup_theme','maior_add_role_function');
function maior_add_role_function(){
$roles_set = get_option('my_roles_are_set');
if(!$roles_set){
add_role(
'maior-admin',
'mj admin',
array(
'manage_sites' => true,
'read' => true,
'edit_posts' => true,
//set all capabilities needed - you could do this with get_role() but not so straightforward
)
);
update_option('my_roles_are_set',true);
}
}