The MU forums have moved to WordPress.org

How to make a newly registered user, contributor on all existing blogs? (4 posts)

  1. rahul286
    Member
    Posted 14 years ago #

    Dear All,
    I just started playing with wordpress MU.
    I have been actively working on Wordpress since long time and running more than 10 blogs in our blog-network. Since blog network is growing, I thought its good idea to go for WPMU.

    Now about our setup...
    We have a blog n/w say at blog-nw.com
    All blogs in network have their own domain name but I am using Doncha's Domain Mapping plugin to tackle this issue.
    Next all blogs are community blog. Till now I was using "define('CUSTOM_USER_TABLE', 'wp_users')" option in wp-config.php of all blogs to share user tables.
    Now on WPMU I am looking for a similar solution.

    Whenever a user register on any WPMU blog, he must be assigned contributor status on all blogs available in that installation.

    Also if a tomorrow a new blog is created in network, it must have assigned all user on network automatically assigned to it.

  2. donaldd
    Member
    Posted 14 years ago #

    Rahul. Did you ever discover an answer to this problem? If so, I'd be interested to hear of it. Donald.

  3. reboltutorial
    Member
    Posted 14 years ago #

    Still no answer :)

  4. DeannaS
    Member
    Posted 14 years ago #

    <?php
    /**********************
    Plugin name: whatever you want to call it
    Description: Your description
    Version: 1.0
    Author:
    Copyright:
    **********************/
    
    function set_user_role($user_id){
    $bloglist = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d  AND archived = '0'  AND spam = '0' AND deleted = '0' ORDER BY path", $wpdb->siteid), ARRAY_A );
    
    foreach ($bloglist as $blog) {
       add_user_to_blog( $blog['blog_id'], $user_id, 'contributor' );
    }
    }
    
    add_action('wpmu_activate_user', 'set_user_role', 100, 2);
    ?>

About this Topic

  • Started 14 years ago by rahul286
  • Latest reply from DeannaS