Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mkdizajn/5291247 to your computer and use it in GitHub Desktop.
Save mkdizajn/5291247 to your computer and use it in GitHub Desktop.
How to Allow Administrators to Edit Users in a WordPress Network
<?php
/* wordpress multisite how to allow administrators to edit users! */
function mc_admin_users_caps( $caps, $cap, $user_id, $args ){
foreach( $caps as $key => $capability ){
if( $capability != 'do_not_allow' )
continue;
switch( $cap ) {
case 'edit_user':
case 'edit_users':
$caps[$key] = 'edit_users';
break;
case 'delete_user':
case 'delete_users':
$caps[$key] = 'delete_users';
break;
case 'create_users':
$caps[$key] = $cap;
break;
}
}
return $caps;
}
add_filter( 'map_meta_cap', 'mc_admin_users_caps', 10, 4 );
?>
@DanLockcuff
Copy link

Hello, Thanks for this, is this to be added to capabilities.php or in a separate file? I have found similar code to this just no instructions as to where it goes.

@stiucsib86
Copy link

You can create a file in /wp-content/mu-plugins and paste the code above.

@cip8
Copy link

cip8 commented May 15, 2017

Great - I was looking for this. This is very helpful - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment