I've setup a WP MU site and I need to know how to sign up a user to a specific blog when they register. As it is now, if a visitor is visiting a specific site and they click the register button they are taken to the main network site and then they are given the option to register as a user or create their own blog.

I can create my own registration page but I'm not sure how to add that user to a specific site.

This is what I have so far:

$meta = apply_filters( 'add_signup_meta', array() );
$emailSent = wpmu_signup_user( $user_name, $user_email, $meta );

I think I found it,

<?php add_user_to_blog( $blog_id, $user_id, $role ) ?> 


| improve this answer | |

This works if you do not have a confirmation email, but you then have to hook activation to use add_user_to_blog. WordPress will add a user to an existing blog (now known as a network site) on user activation if you provide a couple of meta data fields:

$user_blog_id = 2; // or get_current_blog_id(), etc.
$user_meta = [
    'add_to_blog' => $user_blog_id,
    'new_role' => 'subscriber' // or any other role your site has...
// WordPress has a built-in action on activation to look
//     for the above fields and assign the user to a
//     given blog id (network site) and role.
\wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', $user_meta ) );

See add_new_user_to_blog for more information (this is the function called through an action on user activation that assigns the user to a blog [network site] using the meta fields in the example above).

| improve this answer | |

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.