WordPress.org

Ready to get started?Download WordPress

Forums

Adding All New Users to Main Site (43 posts)

  1. agreda
    Member
    Posted 3 years ago #

    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.

  2. Okay. Looking at that real fast

    wpmu_new_blog specifies the creation of new BLOGS.

    So. Maybe try using user_register instead? Something that calls user registration, basically. Maybe user activation...

  3. wpmu_new_blog specifies the creation of new BLOGS.

    Good catch. :) Yes, this is why it's only doing it on new blog creation and not new *user* creation.

    wpmu_new_user is the one you need.

  4. Ah, there you are then :) I call user_register for another plugin. Wasn't sure what you'd want for this one :D

  5. agreda
    Member
    Posted 3 years ago #

    As usual, y'all rock. And now for the proverbial, however...

    Changing wpmu_new_blog to wpmu_new_user results in the following error on the activation page:

    Warning: Missing argument 2 for ds_new_user_meta() in /home/triblogs/public_html/wp-content/mu-plugins/new_user.php on line 3

    Here is line 3:
    function ds_new_user_meta($blog_id, $user_id) {

    Interesting aside: Just confirmed using wpmu_new_blog does not throw the error.

    Using user_register results in the same error. What am I missing here? Should there be a $thing that indicates user level after that $user_id thing? Or am I obviously just clueless?

    Thanks again!

  6. squidgemonster
    Member
    Posted 3 years ago #

    Hi agreda - thenbrent has just done an update to his great plug-in to fix the non-registration on the main/blog ID 1 site:

    http://wordpress.org/support/topic/plugin-multisite-user-management-update-for-31

    I can't speak for him, but I'm sure this will be pushed out as an update for the main plug-in shortly.

    I'm a little confused why this pseudo subscriber role is created for network sites as it creates quite a few problems, especially as general plug-ins tend to refer to users by role, not by capabilities... I've had to add hack/add 'can_edit' statements to adjust content for these 'ghost users' who don't appear to belong to any blog...

  7. wpmu_new_user makes a different call... I think it's this?

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

    That's a WAG, mind you.

  8. agreda
    Member
    Posted 3 years ago #

    @Ipstenu Thanks, but that's the code that threw the error in my last post.

    And forgive me, but it must not be my week for deciphering obvious acronyms... WAG?

    @squidgemonstr Thanks, I'll check that out.

    I too am at a loss about the whole "pseudo" thing – why not just make them subscribers, or don't.

    Any ideas how we might get dsader (the ds in ds_new_user_meta, i believe) to take a look at this?

  9. it must not be my week for deciphering obvious acronyms... WAG?

    wild-ass guess. ;P

    I too am at a loss about the whole "pseudo" thing – why not just make them subscribers, or don't.

    because you don't want someone physically attached to all blogs and show up in each blog's users menu.

    this way, their "pseudo"-ness allows them to use the "must be logged in to comment" but doesn't give them any kind of dashboard access on every single blog in the network.

  10. agreda
    Member
    Posted 3 years ago #

    @andrea thanks for the clarification. Makes sense for all blogs, I just feel the should be "real" users of site 1, perhaps via a superadmin option... or maybe I'm just being selfish since that's what I'm trying to get working again with this script that stopped working after upgrading to 3.1.

  11. FYI: They need to be registered members of site id 1 where our SimplePress forums reside.

    Yeah, you/we/someone needs to find the right code snippet to manually make sure all users are physically added to blog 1.

    And I just notcied you said SITE ID 1.

    no.

    You want BLOG ID 1.

  12. agreda
    Member
    Posted 3 years ago #

    [sigh] I thought since wp rolled in mu, "Blogs are now called Sites; Site is now called Network."

    Thanks again for the help! Hoping someone else might be able to shed some light on the answer...

  13. Yes, on the front end site == blog

    On the BACK end ... Um. Chimera is the word that comes to mind right now.

  14. David Sader
    Member
    Posted 3 years ago #

    How 'bout 'dis?

    function ds_new_user_meta_2($user_id) {
    add_user_to_blog('1', $user_id, 'subscriber');
    }
    add_action( 'wpmu_new_user', 'ds_new_user_meta_2');
  15. squidgemonster
    Member
    Posted 3 years ago #

    How are you getting on agreda?

    The change WP 3.1 has caused all manner of issues with the 'subscriber access' vs actual 'subscriber' for the network, group, family(?!) of sites. I have to say that the plug-in I referenced fixed all the issues though as you can assign default user subscription levels to each blog/site(?!) which in turn will make them appear in the site admin for each site you'd like :)

    I do think you're right in asking if there is reason in WordPress's madness for creating the psudo role to make it more flexible for the way that people might use multi-site set-ups... but I can't see one.

    Anyway, hope you're making progress.

  16. squidgemonster - There is a reason. I suspect what you meant is not 'I can't see one' and really is 'I can't see why they thought that reason was good enough.' :)

    As Andrea said, in this thread

    because you don't want someone physically attached to all blogs and show up in each blog's users menu.

    And that, validly, has a point.

    WordPress.org Multisite now behaves like WordPress.com. You sign up for a blog but unless you get assigned a role to the blog, you're not a 'member' of the blog. And you know... that's sensible. You have no real role as a psudeo-subscriber. nor do you need on.

    http://core.trac.wordpress.org/ticket/14696

    Part of the goal with moving the menus to Network Admin is that the whole 'Dashboard Blog' concept was a massive annoyance to everyone code-wise and UI wise. Having to say "Oh yeah, the main site is the master site AND it's where I control the universe" is logistically unsound. Much like you cannot in-line edit posts, you should not be mixing up Admin and User areas.

  17. [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.)

  18. agreda
    Member
    Posted 3 years ago #

    @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.

  19. agreda
    Member
    Posted 3 years ago #

    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.

  20. 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!

  21. Greg
    Member
    Posted 3 years ago #

    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 );
    
  22. 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.

  23. vitoreis
    Member
    Posted 2 years ago #

    @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!

  24. 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!)

  25. agreda
    Member
    Posted 2 years ago #

    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!

  26. vitoreis
    Member
    Posted 2 years ago #

    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...

  27. petriknz
    Member
    Posted 2 years ago #

    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

  28. 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.

  29. 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.

  30. 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.

Topic Closed

This topic has been closed to new replies.

About this Topic