The MU forums have moved to WordPress.org

How-to register new users to sub-blogs with default roles (23 posts)

  1. merqtio
    Member
    Posted 17 years ago #

    Hey folks, there are several different threads trying to solve the problem of allowing users to self-register on a sub-blog (i.e. not the main blog) and assigning them a default role, so I'm going to try to summarize and consolidate them into one thread here.

    1. New users signing up at the main blog were not getting default permissions, which seems to have been either avoided or fixed. However, this still left the problem of people trying to register as users on sub-blogs.
    2. A hack was offered that will allow users to click on a register link in the meta widget (although this may no longer be working according to more recent comments).
    3. However, dubaidan ran into trouble when clicking on the 'Register' link in the meta widget because it links to 'sub-blog.whatever.com/wp-login.php?action=register', which looks just like the login pane (I cannot find a do_action argument in 'wp-login', so I wonder if there is an error here).
    4. Finally, even when one does the above and gets to the login pane that has a link to 'Register', this links to 'sub-blog.whatever.com/signup/', which is a dead-end at best and a 404 error at worst. dubaidan confirms this.

    So to summarize the question based on the above:
    Can anyone figure out how to (1) allow a person to sign up as a new user on a sub-blog (such that he belongs to the sub-blog and not the main blog) and then (2) automatically assign them a default role such as 'Author'?

    This seems like such a basic and essential function for a sub-blog, that I can't believe it's not there. Am I just overlooking it?

  2. andrea_r
    Moderator
    Posted 17 years ago #

    Dunno. I'm off checking...

  3. andrea_r
    Moderator
    Posted 17 years ago #

    You're goign about it backwards. :) This is one of the regular WP things that is changed in MU.

    For someone to sign up as a user to a *specific* blog, they have to be signed on to the whole system. Either as just a user, or a user with a blog.

    Then the admin of a particular blog can add a user from the community and assign a default role.

    Why the single-blog signup link doesn't redirect to the system-wide sign up, I dunno. Probably an oversight. That link (the first one) shoudl be replaced in any themes it appears in, or you could add a link to the login page to redirect to the blog signup page.

  4. merqtio
    Member
    Posted 17 years ago #

    Thanks for looking into this. The way MU does it seems a little unintuitive though; picture this scenario:

    The average user finds a sub-blog while googling and wants to become an author on that sub-blog. He gets redirected to the main blog to register a username only and now has, let's say, subscriber privileges on the main blog. He may or may not realize that he has not actually signed up for the sub-blog, which could cause some confusion. When he does realize he's not signed-up for the sub-blog, what does he do next? Does he email the admin of the sub-blog or leave a comment on the sub-blog so that he can be added by the admin with author privileges?

    What do you think is the most efficient and least confusing way to have new user and sub-blog admin connect?

  5. lunabyte
    Member
    Posted 17 years ago #

    I think it's more of a general protection/precaution.

    IMHO, I have no idea why someone would want to freely give out author level permissions to anyone that felt like signing up.

    I could understand subscriber maybe, but author? To me, that's plain nuts and one big security hole.

  6. merqtio
    Member
    Posted 17 years ago #

    Well, the focus of the blog network I'm working on is recruitment of multiple authors to each of the sub-blogs to provide content, so it makes sense in this context; forgive my ignorance but besides spam, what would the security hole be?

    But ok, let's assume that the users would instead get subscriber or contributer roles on the sub-blogs and the admins of each sub-blog could promote them later: the question is still what would be the best way for newly subscribed users on the main blog to get connected to a sub-blog?

  7. andrea_r
    Moderator
    Posted 17 years ago #

    Have a post or sidebar blurb explaining the sign-up procedure.

  8. merqtio
    Member
    Posted 17 years ago #

    Fair enough, I guess there's no other way to do it. Thanks for the help; much appreciated.

  9. andrea_r
    Moderator
    Posted 17 years ago #

    Well, in every blog I've seen that had a call for authors to contribute, there was always a post or page explaining the procedure - even on stand-alone WP blogs. Like luna said, you don't really wnat just anyone coming along and getting author privledges on your blog - they get a bit more than that.

    http://codex.wordpress.org/Roles_and_Capabilities#Author

    At this level, I think they can delete other author's (same level) posts.

    one would think a new author on a blog would have to go through some sort of approval. Just to stick to your outlined scenario, anwyay. :)

  10. dubaidan
    Member
    Posted 17 years ago #

    Let's put this scenario aside and ask ourselves, do we need/want to allow users to register and should there be a working sub-domain and sub-dir blog registration page. It's a feature that exists in the single user version, so why not in MU.

    I need to limit comments to registered users on all blogs, it's a requirement of where I work. I can turn this feature on, but it's not possible for anybody to register.

    I also have a support blog for WPMU, I want all users to be able to comment and save new posts, (not publish). So I want to allow registration with the default user level set to contributor. (you can do this in the single version of WP)

    Merqtio in his original post, collated the various problems and I believe they still exist.

    Can anybody offer advice on where WordpressMU is heading with regards to registration? This is a crux point in our adoption of WPMU.

  11. miteshashar
    Member
    Posted 17 years ago #

    This is what I did...
    and its workin cool...
    my motive was to let the user register as a subscriber to the present blog...let him subscribe...and allow him 2 comment anywhere on my site...apart from that...no new user may be able to create a blog...creating blogs is only done by me...and i manage who is the author of which blog

    wp-signup.php

    Just comment the following function defnitions:
    - show_blog_form
    - validate_blog_form
    - signup_another_blog
    - validate_another_blog signup
    - confirm_another_blog_signup
    - signup_blog
    - validate_blog_signup
    - confirm_blog_signup
    Now, in the function signup_user(), comment the lines shown below:

    <th scope="row" valign="top"> </th>

    <td>

    <p>

    <?
    //<input id="signupblog" type="radio" name="signup_for" value="blog" checked="checked" />

    //<label for="signupblog"><php _e('Gimme a blog!') ?</label>

    //
    ?>

    <input id="signupuser" type="hidden" name="signup_for" value="user" />

    <?//<label for="signupuser">php _e('Just a username, please.') ?</label>
    ?>

    </p>

    In the function validate_user_signup(), comment the shown lines:

    if ( $errors->get_error_code() ) {

    signup_user($user_name, $user_email, $errors);

    return;

    }

    /*

    if ( 'blog' == $_POST['signup_for'] ) {

    signup_blog($user_name, $user_email);

    return;

    }

    */

    wpmu_signup_user($user_name, $user_email);

    Now, in the switch case at the end, comment the cases validate-blog-signup and gimmeanotherblog.

    In the default case, replace the code by:

    default :

    $user_email = $_POST[ 'user_email' ];

    do_action( "preprocess_signup_form" ); // populate the form from invites, elsewhere?

    if ( is_user_logged_in() )
    echo 'You are already logged in';

    //signup_another_blog($blog_id);

    else

    signup_user( $blog_id, $user_email );

    /*if ($blog_id) {

    if( constant( "VHOST" ) == 'no' )

    $newblog = 'http://' . $current_site->domain . $current_site->path . $blog_id . '/';

    else

    $newblog = 'http://' . $blog_id . '.' . $current_site->domain . $current_site->path;

    printf(__("<p>The blog you were looking for, %s doesn't exist but you can create it now!</p>"), $newblog );

    }*/

    break;

    OK, that was the part in wp-signup.
    Now,

    wp-activate.php
    Here we will just need to add one function call after the following lines of code:
    56 $url = get_blogaddress_by_id($blog_id);

    57 $user = new WP_User($user_id);
    58 //Code to make user subscriber of sub-blog by default
    59 add_user_to_blog($blog_id, $user_id, 'subscriber');

    you may replace subscriber by anything u want...

    Now, we will go about modifying wpmu-functions.php in the include folder:
    In the function wpmu_signup_user_notification(), replace $current_site with $current_blog (There r 3 occurrences :-) )

    We can now still customize it to our whims and fancies, which I'm gonna do in future.
    Will try 2 keep u posted.
    Thanx

    Note: Please add on anything that u would like 2

  12. rarecopy
    Member
    Posted 17 years ago #

    Hi there,

    I'm new to wp and wpmu but if i look at this website:

    http://www.ntmy.org
    and signup at
    http://ntmy.org/wp-signup.php

    i get my own folder ntmy.org/myfolder
    and my own blog ntmy.org/myfolder/wp-admin/

    and it's all automatic... so in someway this all IS possible! I'd like to know in what way.

    As merqtio stated this is such an essential and basic function. Maybe the keyfeature which people expect when they read wp MULTI USER support.

    Anyway lets find some more solutions :)

    Cheers

  13. drmike
    Member
    Posted 17 years ago #

    Um, that's a standard install using subdirectories. Just install the software in root and select the subdirectories option. Be sure to read the docs that come with the download.

  14. rarecopy
    Member
    Posted 17 years ago #

    drmike, i know about the subdirectory option. But i mean. i need to solve the problem "allowing users to self-register on a sub-blog (i.e. not the main blog) and assigning them a default role" aswell. And at http://www.ntmy.org hey somehow managed to do so. I'm curious how they've done it. Cause i'm asked to do something similar.

  15. awacht
    Member
    Posted 16 years ago #

    Hi, I've tried the code changes suggested my MITESHASHAR with high hopes. I'm unfortunately not able to get it to work. The user ends up registered for the main blog, but does not become a subscriber for the sub-blog. I'd be happy to post my files if someone wants to be so kind to take a look. From what I can tell though, I've done the edits exactly as described.

    I personally fail to understand why wpmu was engineered so that an admin has to manually add a user to a sub-blog. I can understand the control, but it really turns out to be a pita. We like to require registration for posting comments and such, each user can have subscriber level privledges to do so, but the amount of admin interaction necessary really makes this an annoyance for our blog readers. Our master blog has nothing for readers, it's really only for admins. Our sub-blogs are where the action is, so to speak. We really don't want anyone to be subscribers to the main blog, only the blog they are interested in, and the one from which they've registered.

    I'd love to get htis working if anyone has any insight.
    Thanks

  16. thatsmyteam
    Member
    Posted 16 years ago #

    Hello,

    I have got MITESHASHAR code working. After doing all the changes go to wp-signup.php and comment out the following (around line 8):

    
    /*
    if( $current_blog->domain != $current_site->domain ) {
    	header( "Location: http://&quot; . $current_site->domain . $current_site->path . "wp-signup.php" );
    	die();
    }
    */
    

    This makes the user sign up to the current blog as a subscriber and also gives them subscriber access to the main blog.

    Works very well as the sign-up page and activation page all run through the current blog with its theme.

    Thanks

    Simon

  17. spanner
    Member
    Posted 16 years ago #

    Might it be possible to accomplish most of miteshashar's function changes in a different way - by changing the code to allow only user signups? Around line 370 of wp-signup.php, change

    $active_signup = 'all';

    to

    $active_signup = 'user';

    and then comment out the next line:

    //$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"

    I'm still working on this - haven't got it entirely figured out yet.

  18. lunabyte
    Member
    Posted 16 years ago #

    Even easier, just comment out the radio button/text for the blog option, and then make the username the selected value.

    Might want to put a quick style of display:none on that field too. Then it's always selected, and the user never sees it.

  19. nkinkade
    Member
    Posted 16 years ago #

    I put together a plugin that seems to address most of the issues the original poster mentions. I wrote if for Creative Commons (http://creativecommons.org), but noticed that there are quite a few posts about trying to get per-blog registrations working. So, I thought I'd just post the plugin here in the hope that it might be useful to someone else. There might be bugs in it, but it seems to be working as expected here. This plugin does not try to set the default role of new users, but I imagine that that is pulled in from the sub-blogs config. The file has quite a few inline comments.

    http://cctools.svn.sourceforge.net/viewvc/cctools/ccwordpress/trunk/mu-plugins/per_blog_registrations/

    Saludos,

    Nathan

  20. xstrmn8rs
    Member
    Posted 16 years ago #

    How do I install the plugin? tried putting it in plugins and the mu-plugins folder

  21. jehanproc
    Member
    Posted 16 years ago #

    Any news on this post ? we use wordpressMU internally (intranet) with an SSO (cas) on the wp-login page, so it's not a security problem here to get new subsrcibers to get a default "author" role .
    Anyway, mostly, I want new users to subscribe (as author if possible ...) directly in a sub-blog. what is the best way to do it, miteshashar's hack on wp-signup.php or nkinkade's plugin which end up to an "unknow location" :-( !!, or whatever new feature with the current 1.3.3 wpmu release ?
    thanks.

  22. nkinkade
    Member
    Posted 15 years ago #

    Here is another thread that has an updated link to the plugin:
    http://mu.wordpress.org/forums/topic.php?id=5636 We recently moved our subversion repositories to a server of our own. The new URL is this: http://code.creativecommons.org/viewsvn/wordpressmu/trunk/mu-plugins/per_blog_registrations/ I haven't touched this for a while, but if anyone has any suggestions/questions please feel free to contact me at nkinkade@creativecommons.org.

  23. abhic
    Member
    Posted 15 years ago #

    I am looking for any user to sign up into their own blog and only be assigned contributor status. Then the system Editor (admin) approves each of the posts.

About this Topic