WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Trying to figure out how to have users created automatically when a network site is created.

So currently when a new user registers, their account is created and their network site is created. That gives that new site one user already (the site's admin). But when that's created I'd like to also have 3 more users automatically created to each new network site on creation.

share|improve this question
up vote 0 down vote accepted

You can do that hooking into wpmu_new_blog and then creating the user if it does not exists, and adding that user to the blog being created. To do so, you will use a code like this ( only for 1 user) , as a network enabled plugin or on the main theme functions.php


function wpse_29543_new_blog($blogid){
    $user_id = username_exists( $user_name );
    if ( !$user_id ) {  
        $user_id = wp_create_user( $user_name, $user_password, $user_email );
    add_user_to_blog( $blogid, $user_id, $role );

share|improve this answer
doesn't seem to work. – JonnyPlow Sep 26 '11 at 23:16
Where did you add this code – Hansy Schmitt Sep 26 '11 at 23:21
I take that back. It does work. I just needed to try it when I created the new site. I was only trying on refresh. Awesome, thank you!! – JonnyPlow Sep 26 '11 at 23:52

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.