• Starting a new topic as requested…

    It is my understanding that all new registered users under WP 3.1 MS are automatically assigned Subscriber status to blog ID 1, but this clearly does not seem to be the case (at least for us at tripawds.com) as they are not being listed under Site Admin as a user of the main site. The exception, however, is that new users who also create a blog/site are being assigned subscriber status to blog id 1. Those who create no site, are not.

    Now, we have been using the following in mu-plugins to automatically assign all new users main blog Subscriber status:

    function ds_new_user_meta($blog_id, $user_id) {
    add_user_to_blog('1', $user_id, 'subscriber' );
    }
    add_action( 'wpmu_new_blog', 'ds_new_user_meta', 10, 2 );

    It’s been working like a charm, until our 3.1 upgrade. Since then, only users who create a site are being added to the main site.

    So… My questions include:

    • Should all new users (with or without a bblog) appear as subscribers under the primary site admin / users?
    • Could this “new-user” plugin be keeping WP from doing its job?
    • Any suggested tweaks for getting this plugin working again under WP 3.1?

    Many thanks to all for any input.

    I did look into macbis’ Multisite User Management plugi, however, it appears to assign users to all sites, and we only want to add new users to site id 1. FYI: They need to be registered members of site id 1 where our SimplePress forums reside.

Viewing 15 replies - 16 through 30 (of 42 total)
  • [sigh] I thought since wp rolled in mu, “Blogs are now called Sites; Site is now called Network.”

    Only in the admin areas, not in the code itself. JUST to keep us on our toes.

    (not really, that’s for backwards compatibility. renaming all that stuff would break things like whoa.)

    Thread Starter agreda

    (@agreda)

    @david Thank you for checking in on this! Your new snippet adds new users without any error, but now only if they do NOT create a blog. Those who create a blog do not get added via this.

    Still hacking away and testing to see if I can get both working in one plugin. All suggestions appreciated.

    Thread Starter agreda

    (@agreda)

    OK. After trying to set the record for most test users created, I think I have the following working to auto-add all new users to the main site, whether or not they create a blog upon signup…

    function tri_new_user($user_id) {
    add_user_to_blog('1', $user_id, 'subscriber');
    }
    add_action( 'wpmu_new_user', 'tri_new_user');
    
    function tri_new_blogger($blog_id, $user_id) {
    add_user_to_blog('1', $user_id, 'subscriber' );
    }
    add_action( 'wpmu_new_blog', 'tri_new_blogger', 10, 2 );

    Before I deploy this on our live site, I’m open to any feedback regarding whether this could wreak any unforeseen havoc, or if there might be a cleaner way to do this.

    Thanks for all the great input! Progress is a good thing.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    If there’s a way to check IF they’re making a new blog, maybe wrap that around your code? but that’s a nice catch, David!

    In case it is useful, this is what I have been doing since 3.1. I added this in functions.php in the theme of the main blog. I am using the ‘wpmu_activate_user’ hook because that is fired close to the place that pre-3.1 WordPress would assign blogless new users to the main blog.

    Note that in my situation we don’t allow new users to create blogs so YMMV.

    function _activate_user( $user_id, $password, $meta )
    {
        // Ensure that new users are registered to the main blog
        add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    }
    add_action( 'wpmu_activate_user', '_activate_user', 10, 3 );
    

    I added this in functions.php in the theme of the main blog.

    But if you hcange your theme you are hosed.

    The normal process in multisite is to add the mu-plugins folder and place your code in a file in there.

    @andrea_r Can you point a direction to a newbie “add the mu-plugins folder and place your code in a file in there.”?

    Thank you!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    1) Create a folder on the same level as plugins called mu-plugins

    2) Make a file called activate-user.php with the content:

    <?php
    
    function _activate_user( $user_id, $password, $meta )
    {
        // Ensure that new users are registered to the main blog
        add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    }
    add_action( 'wpmu_activate_user', '_activate_user', 10, 3 );
    
    ?>

    3) Put that file in the mu-plugins folder

    4) Pizza and beer!

    (added PHP tags per the post below!)

    Thread Starter agreda

    (@agreda)

    direction to a newbie…

    Clarification for true noobs: you must wrap that code in php open and close tags to make it a working script!

    Thanks Ipstenu! I do that but don′t see all new users added to main site. We don’t allow new users to create blogs to YMMV, they just add comments in existing blogs.

    Think I need to learn I little more how to debug in WP…

    Is it possible to get a complete write up of how to do this from the word go? Along with the options mentioned for if they create sites or not. Also once implemented are the people that already registered automatically added to the blogs or do they need to re register?

    This ‘feature’ has locked out my readers who can’t get to my forums, and they’re not happy. I need to get this sorted ASAP

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Thanks Ipstenu! I do that but don′t see all new users added to main site. We don’t allow new users to create blogs to YMMV, they just add comments in existing blogs.

    They don’t need to be members of the site for that. You only need to be a site MEMBER if there are features like writing posts or something with a membership plugin that requires it. Otherwise registered users who aren’t members of that particular site, can still comment.

    This ‘feature’ has locked out my readers who can’t get to my forums, and they’re not happy. I need to get this sorted ASAP

    Not everyone has a forum attached to their site. ??

    in that case, you *may* have to use the code mentioned above to add people as a user to what blog the forum is attached to. then the *forum* software will see they are “legit” users.

    Along with the options mentioned for if they create sites or not.

    Not sure we’d need a whole writeup for changing a radio button on the registration options.

    Network Admin -> Settings.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Also that greatly depends on your forum. bbPress Plugin just hit alpha (I think… I’m working on 4 hours sleep). It’s not the only one.

    I wish I understood the code. How do I work out what the blog is?

    So then once that is in plugin those user should just show up? Or do they need to re register?

Viewing 15 replies - 16 through 30 (of 42 total)
  • The topic ‘Adding All New Users to Main Site’ is closed to new replies.