0

When an Administrator for a sub site removes a user from their sub site, I am trying to not only remove the user, but also completely delete them from the entire MU site. I have tried this:

add_action( 'remove_user_from_blog', 'custom_remove_user', 10,4 );
function custom_remove_user( $user_id ) {
     wpmu_delete_user( $user_id );
}

but i am not able to get it to work - it is not actually deleting the user and it fact when creating the user it is not being assigned to the proper sub site.

If I input an actual number of an existing user, the function works properly.

Any other suggestions for how to handle this?

  • The users table is the same for the whole WordPress MU. Have you checked your error logs? – prosti Jan 5 '17 at 17:42
  • @prosti what error logs would i check as I am not seeing any in the generic cPanel error log section. – whodeee Jan 5 '17 at 18:57
0

If I input an actual number of an existing user, the function works properly.

The same user may exist on some other website on your MU farm. Try figuring out the problem from the error log. Is your admin also super admin?

File: /wp-admin/includes/ms.php

192: function wpmu_delete_user( $id ) {
...
206:    $_super_admins = get_super_admins();
207:    if ( in_array( $user->user_login, $_super_admins, true ) ) {
208:        return false;
209:    }

This may be the problem. Only super admins can remove the users.

  • The user is a newly created user with Editor role only associated with the given site. – whodeee Jan 5 '17 at 19:09
  • I am trying to add that capability to the Administrator, do you know if that is possible? – whodeee Jan 5 '17 at 19:55
  • That would be the another question @whodeee. It would be hardly desirable to create another quest with the title. Make the administrator super administrator. – prosti Jan 5 '17 at 19:59
  • @whodeee, identifying the problem is not a bad thing. Please make sure you tick my answer if possible ✓. – prosti Jan 5 '17 at 20:03

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.