3

I'm making a front-end user delete button but it only removes the user from the current installation and I need to remove them from the entire multisite network so they are able to sign up again with the same email if they decide. Is there a way to do this?

$userid = get_current_user_id();
wp_delete_user( $userid );
2
  • Can we see the current implementation? Edit your question and insert the code that does the deletion
    – Tom J Nowell
    Commented Sep 22, 2018 at 0:18
  • 1
    Yes I just added
    – Miguel Dey
    Commented Sep 22, 2018 at 0:31

1 Answer 1

8

You would want to use wpmu_delete_user:

$userid = get_current_user_id();
wpmu_delete_user( $userid );

Deletes a user from the network and removes it from all sites.

https://developer.wordpress.org/reference/functions/wpmu_delete_user/

1
  • Totally agree the function is the way to go, but the demo code seems a little dangerous as it would delete the current user. Rarely what you'd want to do, and could cause some serious issues for anyone blindly copying and pasting :) (I've been there). Would recommend changing to just a random integer with a note to change it in comments Commented Oct 24, 2023 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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