I am using WordPress MU 2.92 and I need a way to add users to all the blogs (existing blogs and new blogs yet to be added).
I have a closed blogging network and all bloggers are added manually via the admin panel.
So I need to add a user as an author on all blogs. I am using the sub-directory MU option if that matters.
I found a solution on this page - http://mu.wordpress.org/forums/topic/9913
and added the file called add-users.php to my plugins folder with this code:
<?php
function add_new_user_to_all_blogs($user_id)
{
global $wpdb;
$blog_list = $wpdb->get_results("SELECT blog_id FROM " . $wpdb->blogs);
foreach ($blog_list as $blog)
{
add_user_to_blog($blog->blog_id, $user_id, 'author');
}
}
add_action('wpmu_new_user', 'add_new_user_to_all_blogs', 10, 2);
?>
It added the user to all blogs but it did not set the user's role - actually there was no role assigned.
How can I tweak this code (or replace it) so that 1) the new user is added to all blogs, and 2) the new user role is author?