Support » Networking WordPress » user registration pre-enrolled to original blog in multi-site blog

  • I’ve commented on a few posts, but thought I would start my own thread…

    __Brief outline:__
    I want a user to be able to register on a sub blog (and not be handed off to the root account) of a multisite install, and the user activates their account and is automatically granted specific rights on THAT SITE ONLY.

    __Long version:__
    I have 3 questions, detailed below, but first, the background…

    I have a multisite install with several sub-blogs. I am aware of the “default” behaviour of registration whereby a new user submits the registration, checks their email, activates their account (ie, confirms their email) and is then placed in a “dead-zone” until an admin comes by and adds the user to a blog.

    I know there is a plugin that will allow you to set default roles for different sites (across all sites), but this is not a suitable fix as this gives the user access to multiple sites that really are quite irrelevant and maybe even detrimental in a competitive sense. The plugin also doesn’t distinguish where the user came from (ie, which site) and apply only the correct role for the blog the user registered–if there is a plugin for this, I would like to know about it.

    I have broken this down into a 2 step process:

    1. have the user remain on the blog that they are registering with (and not being palmed off to the root blog, and
    2. adding a default role for the user, for that particular blog they are registering/activating with.

    I have achieved point 1 by editing out the relevant sections of wp-signup.php and wp-activate.php. So, my first question is:

    Q1. Is there any detrimental effect to doing this? The user is still added to the database with exactly the same capabilities as a user added before making these changes. They still have no capabilities with any blog other than being able to view their profile. They are in the database – just not associated with any blog.

    I am stuck at point 2. I know where I should be editing, but I don’t know what to put there exactly. I have identified the portion of code I want to add to within wp-activate.php:

    $url = get_blogaddress_by_id( (int) $blog_id);
    $user = new WP_User( (int) $user_id);
    // <!-- I want to add a line of code here... -->
    <h2><?php _e('Your account is now active!'); ?></h2>

    I know I want to use the add_role function, but I don’t know how to call it safely and to make sure that the correct capabilities are added to that role, if they need to be… And to make sure it’s only added for the specified blog.

    I’m thinking something along the lines of $user->add_role( $role_name ); where $role_name should/would equal “subscriber”???

    Q2. How do I correctly call the add_role function, adding the user to the subscribers role for the blog they are currently activating? I want to call it using correct wordpress protocols, such that should “subscriber” (or “Subscriber”) be hardcoded into the code? I’m thinking not. Should I use the get_role function to determine the text to use? I usually do just play around and try things and see what happens, so I’m sorry if it’s a stupid question, I just don’t want to “experiment” in this area.

    Final question:
    Q3. wp-activate.php and wp-signup.php are not located in the template file area. How do I correctly override these files? Or should I NOT be overriding them at all? Ok, technically not one question. :^) Can I just place a copy in the child theme I have created for these sites? Or are these files that are not meant to be overridden?

    BTW, I have been searching for an answer for this for over a week now and this seems to be a common problem to which there is no documented solution (that I could find). I am determined to come to a solution and hopefully it can be documented here. Most threads on this topic have died off and been closed, although there are a couple that I have found to be open at the moment but still have no solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    Becoming a member(subscriber) of a particular blog after signup to the network can be done in a roundabout way through the backend or a frontend widget:

    I know, not the best solution.

    HOWEVER. It looks like has something interesting:

    1. “Users -> Users Extended” – lets you show users lists with the new fields that are created

    2. “Settings -> Cimy User Extra Fields” – lets administrators add as many new fields as are needed to the users’ profile, giving the possibility to set some interesting rules.

    Sounds like they MAY be able to let you trigger per-blog registration.

    You could then leverage something like to make a page the signup page per site, and parse from there.

    For Q3 you can try Profile Builder: (there’s a free version hosted on that should work just fine for what you need.)

    Basically you create registration pages for each of your sub-sites.

    Just create a new page, call it Registrer, add the
    shortcode in that page and you’re done.

    Users registered there will be registering to that blog only.

    You might want to activate Profile Builder network-wide or only for blogs that you want.

    For Q2: Install the Members plugin:

    With it you can create new user-roles to use for each other site, with the exact capabilities you need.

    Once you create the user roles, use the
    ‘[wppb-register role=”myrole”] ‘ shortcode where myrole is the new user role you created with Members.

    For Q1: using the Q3 and Q2 solution I don’t see any detrimental effect doing this.

    Hope this helps you. Let me know if you have questions 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘user registration pre-enrolled to original blog in multi-site blog’ is closed to new replies.