The MU forums have moved to WordPress.org

WPMU Defaults New Blogs User Role To Admin... (8 posts)

  1. arulnick
    Member
    Posted 14 years ago #

    Hello everyone, thanks for taking the time to read this...

    So I decided I wanted to change default role from administrator to editor because I feel like there are too many options for novice users.

    I found on line 1305 - 1321 where the code states the following:

    // Check if the domain has been used already. We should return an error message.
    if ( domain_exists($domain, $path, $site_id) )
    return new WP_Error('blog_taken', __('Blog already exists.'));

    if ( !defined("WP_INSTALLING") )
    define( "WP_INSTALLING", true );

    if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
    return new WP_Error('insert_blog', __('Could not create blog.'));

    switch_to_blog($blog_id);

    install_blog($blog_id, $title);

    install_blog_defaults($blog_id, $user_id);

    add_user_to_blog($blog_id, $user_id, 'administrator');

    So I figure if I modify:

    add_user_to_blog($blog_id, $user_id, 'administrator');

    to something like

    add_user_to_blog($blog_id, $user_id, 'editor');

    that would do the trick but I am worried because I was told that some plug-ins are dependent on administrator roles and I don't want to break my WPMU development environment.

    Could I do something like this instead?

    add_user_to_blog($blog_id, WP_ADMIN, 'administrator');

    add_user_to_blog($blog_id, $user_id, 'editor');

    and it will add both the new user and the primary admin to the blog?

    Greatly appreciate any feedback.

    - Andrew

  2. DeannaS
    Member
    Posted 14 years ago #

    First off, don't hack the core. That's not at all something you want to do and you'll be kicking yourself when the next upgrade rolls around.

    Secondly, there are a lot of examples of code lying around the forums of folks that wanted to change the default user role. So, do what you want to do in a plugin.

    Personally, I've never used the WP_ADMIN constant. Echo it out and make sure it's the value you that you think it is. You can have more than one admin, so you might be getting back an array....

  3. arulnick
    Member
    Posted 14 years ago #

    Changing the core... changing the core...

    MwahaHaHaHa

  4. jalien
    Member
    Posted 14 years ago #

    I posted to a similar question on the Buddypress forums recently. I've played around with the combination of MU and regular plugins that allow me to create new blogs that have limited menus, and with plugins activated with the settings the way I want them done. See if this helps.

  5. arulnick
    Member
    Posted 14 years ago #

    I'm posting this information because I think it could really open up for some innovation in the WordPress user experience. New users don't need massive amounts of tools, widgets and customizations. Really all they need is a dashboard with some default plug-ins. You can't just keep throwing Plug-ins at problems people! RwaR! Hahahaha!

    The solution to an update ruining your original changes is simple, don't automatically update with testing first. Test, test and test again before releasing the latest patch!

    "add_user_to_blog($blog_id, $user_id, 'administrator');
    
    to something like
    
    add_user_to_blog($blog_id, $user_id, 'editor');"
  6. andrea_r
    Moderator
    Posted 14 years ago #

    ... and there's also a Menus plugin which turns off most of the menu items in the bakcend for everyone but admin. ;)

    MwahaHaHaHa

  7. outspaced
    Member
    Posted 14 years ago #

    I couldn't find any code lying around in the forum to do this, so I've done a plugin to handle it:

    http://www.radiolivetransmission.com/2010/03/wordpress-plugin-new-blog-default-user-role/

    I'm new to WP Dev and even newer to WPMU so any feedback is much appreciated :)

  8. arulnick
    Member
    Posted 14 years ago #

    andrea_r the menu plug in is true except WP-MU defaults all newly created blogs default users to admin, this change solves that problem entirely (:

About this Topic

  • Started 14 years ago by arulnick
  • Latest reply from arulnick