I'm writing a custom signup script for users to register with on my MU-setup.

One problem I'm having is that wpmu_signup_user() sends the password activation email but it doesn't return the user ID which I need for the rest of the script. - It's my understanding that this doesn't create the user account, just an entry in the "signup" table.

The other way I've tried is using wp_create_user() which returns the user ID I need (as it creates the user properly) but no email for the user.


If you want to force add a MU user and activate them, and email them, this will do it. It's a slightly altered version of a piece of the code in user-new.php.

wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $blogid, 'new_role' => $role ) );
$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
$ret = wpmu_activate_signup( $key );

The wpmu_activate_signup function will send the welcome email. And the $ret from wpmu_activate_signup is an array of several things, including the user_id in $ret['user_id'].

Obviously you'll need to fill in the user name, email, blogid, and role in the above code.

  • Other lines you need to add: add_filter( 'wpmu_signup_user_notification', '__return_false' ); to disable email verification, and switch_to_blog($blogId) to make sure the email the does go out ha the correct blog URL. – Dunhamzzz Jul 29 '11 at 10:52

Send the email yourself within your signup script with the wp_mail function.

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.