0

I have code to register a user from one of the blogs in WP Multi site:

if($userId = wp_create_user($email, $pass, $email)){
    var_dump(get_user_by_email($email));
}

The problem is that I want them to be registered NOT for the current site, but for the root site of the network.

I know I can use remove_user_from_blog, but it seems like a double work. Is there a way to register a user without attaching them to specific blog ?

2
  • 1
    you'd still need to give them a role on the root site, else they have an account but no roles on any sites
    – Tom J Nowell
    Commented Jul 7, 2019 at 2:19
  • 1
    The devhub documentation for wp_create_user states that this is just a helper function, and that a more comprehensive function exists, is there a reason you chose wp_create_user instead? developer.wordpress.org/reference/functions/wp_create_user
    – Tom J Nowell
    Commented Jul 7, 2019 at 2:22

0

Your Answer

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

Browse other questions tagged or ask your own question.