0

How To Disable "Add new user" On Subsites In WordPress Multisite ?

enter image description here

  • 1
    Why not use the "Members" plugin to disable the feature for any specific role like Admin, Editor, Author, Subscriber etc. Though it's a kind of hiding, but authentically it's kind of disabling too. – Mayeenul Islam Aug 7 '13 at 12:03
2

To remove the Add Users capability from Administrators (but leave it intact for Super Administrators), you can do this:

<?php
$role = get_role( 'administrator' );
if ( $role->capabilities['add_user'] == 1 && ! is_main_site( get_current_blog_id() ) ) {
// Because this is saved to the database, we check first
// to see if it's already been done
    $role->remove_cap['add_user'];
}
?>

Add the code to a plugin in the mu-plugins directory to have it run on each site (whenever the site in question is visited).

Note -- this will remove the capability in the database. To restore it, you'll need to use add_cap().

Reference

get_role()
remove_cap()
add_cap()
is_main_site()
get_current_blog_id()

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.