WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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