Support » Networking WordPress » subadmin subsite-user edit hack/fix

  • Hi all,

    I’m working on a hack/(my opinion)fix for user editing rights for subsite-admin’s. All working with wordpress multisite should have noticed that only a super-admin can edit users.

    In my case I would like that a subsite-admin is also edit to edit his own subsite-members. Therefore I found/created this code for a plugin:

    function mc_admin_users_caps( $caps, $cap, $user_id, $args ){
    	foreach( $caps as $key => $capability ){
    		if( $capability != 'do_not_allow' )
    		switch( $cap ) {
    			case 'edit_user':
    			case 'edit_users':
    				$caps[$key] = 'edit_users';
    			case 'delete_user':
    			case 'delete_users':
    				$caps[$key] = 'delete_users';
    			case 'create_users':
    				$caps[$key] = $cap;
    	return $caps;
    add_filter( 'map_meta_cap', 'mc_admin_users_caps', 10, 4 );
    add_filter( 'enable_edit_any_user_configuration', '__return_true'); // '__return_true' is a WordPress API function in wp-includes/functions.php

    This makes it possible for a subsite admin to edit his users.
    But I’m missing the check if the ‘editable’subsite-user is also a member of the subsite the subsite-admin is logged into!

    Anyone any suggestions how to check if the editable user is member of current subsite?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘subadmin subsite-user edit hack/fix’ is closed to new replies.