The MU forums have moved to WordPress.org

Change Blog Admin Across Many Blogs (3 posts)

  1. deanm
    Member
    Posted 14 years ago #

    Sorry if this was answered elsewhere. I did a search and couldn't find anything.

    I'm looking for a way to change the administrators across many blogs all at once.

    Here's why:

    I run a WPMU installation for a school and many of our students have their own blog. I put the teachers in as the blog administrator so they can monitor them. Now that it's the beginning of the year, I would like a quick way to change last year's teacher to the new year's teacher.

    I downloaded the sql file and found there's a place in the options database of each blog, but that doesn't change the name of the admin that shows up on each blog's Users page.

    Does anyone have any advice? Thanks in advance.

  2. dsader
    Member
    Posted 14 years ago #

    I use WPMU PowerTools and don't know a better solution.

    ( http://mu.wordpress.org/forums/topic/9913 )

    Then paste and execute once

    // adds multiple users to multiple blogs ASAP
    $blogs = array(63,70); //add blog_ids to the crack of doom, class sets
    $users = array(51,52,53); // add one or a tonne of users_ids, teacher or student groups
    $role = 'contributor';
    foreach ($blogs as $blog) {
    foreach($users as $user) {
    add_user_to_blog($blog, $user, $role); // notice order $blog, $user
    }
    }

    In this example, I needed users 50-53 to be added to blogs 63 and 70 as contributors.

    Gathering up user_ids and blog_ids will be tedious, so keep a .txt file in your WPMU dir with "one time" snips of code such as this to use again and again.

    Oh,

    Screwed up and need to remove mass users from multiple blogs?

    $users = array(39,40,41,42,51,52,53);
    $blogs = array(63,70);
    foreach ($blogs as $blog) {
    foreach($users as $user) {
    remove_user_from_blog($user, $blog); // notice order $user, $blog
    }
    }
  3. deanm
    Member
    Posted 14 years ago #

    You're right, that worked perfectly. Thank you so much for your help!

About this Topic