Adding ALL new users to main blog

I'm starting this new topic since this similar discussion is two years old. I also just posted this in the MU forums.

New users who do create their own blog upon sign-up are not being added to our main blog. We've left our "Dashboard Blog" option blank, so users who do not create a blog are getting added to the main blog.

But we are running Simple:stuck_out_tongue:ress forums on the main blog only so we need all new users to be added as main blog subscribers, so they become forum members by default. Whether they create their own blog upon sign-up or not.

Is there a Premium plugin solution (or any other way) to make this happen automatically. I want to avoid manually adding users who have just registered with their own blog, to the main blog, sending them yet another confirmation email?

Thank you all in advance for your help!

PS: Our site is at http://tripawds.com

  • drmike

    Are these new users or for everybody including current users?

    New users: Add this to the signup process:

    add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );

    Reference: http://trac.mu.wordpress.org/browser/branches/2.8/wp-includes/wpmu-functions.php#L1181

    You can actually shorten that since you;re hardcoding:

    add_user_to_blog( '1', $user_id, 'subscriber' );

    Current users: Do that and you're going to have to do a run through script. That was something we had discussed previously. I'll add it to the list. Simple answer is find a 'list all users' plugin, add it to the main blog, edit it so that instead of outputting the data, run that add_user line up there, run it once and then get rid of it.

    There's a hook right below that. Name is 'wpmu_activate_user' if you want to write a small plugin for it of if you use one of the new user default plugins.

    Hope this helps,
    -drmike

  • jwpegram

    I did just that, created a plugin to just add the user to the main blog. The problem I ran into with this suggestion was, using the wpmu_activate_user hooks only seems to fire when a new blog url isn't created. So I changed it up to trigger on wpmu_activate_blog and it works.

    The next problem I found was when an existing user then created a new blog for some reason the user was then removed from the main blog (ie:blog_id=1). Not sure what's doing that, but I ended up firing my add function again on the wpmu_new_blog hook.

    At present it seems to work ok. Here's the plugin code, any suggestion would be welcome.

    //------------------------------------------------------------------------//
    //---Hook-----------------------------------------------------------------//
    //------------------------------------------------------------------------//
    add_action('wpmu_activate_blog', 'add_new_user_to_mainblog', 10,2);
    add_action('wpmu_new_blog', 'add_new_user_to_mainblog', 10,2);

    //------------------------------------------------------------------------//
    //---Functions------------------------------------------------------------//
    //------------------------------------------------------------------------//
    function add_new_user_to_mainblog($blog_id, $user_id) {
    add_user_to_blog( '1', $user_id, 'subscriber' );
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.