References
I found several plugins and solutions for this. The most promising seemed to be MultiUser Management Plugin.
Here’s a short and untested rip off from this plugin, as there’re easier ways to get the available/registered blogs and normally you won’t need their public API functions. Also I think that some stuff they use is already deprecated.
The Plugin
…is, as I said, untested and should just provide a starting point. You’ll have to jump through it, see what works and what doesn’t. Then add what you need.
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (#84066) Register user to all sites upon registration
*/
add_action( 'plugins_loaded', array( 'WPSE84077_register_everywhere' ) );
class WPSE84077_register_everywhere
{
protected static $instance;
public static function init()
{
null === self :: $instance AND self :: $instance = new self;
return self :: $instance;
}
public function __construct()
{
add_action( 'wpmu_activate_user', array( $this, 'add_roles' ) );
add_action( 'wpmu_new_user', array( $this, 'add_roles' ) );
add_action( 'user_register', array( $this, 'add_roles' ) );
}
public function add_roles( $user_id )
{
global $wpdb;
$blogs = $wpdb->get_results( "
SELECT *
FROM {$wpdb->prefix}blogs
ORDER BY blog_id
" );
if ( empty( $blogs ) )
return;
foreach( $blogs as $key => $blog )
{
if ( is_user_member_of_blog( $user_id, $blog[ 'blog_id' ] ) )
continue;
switch_to_blog( $blog[ 'blog_id' ] );
// 'none' role means that user registration won't happen on this blog
$role = get_option( 'default_role', 'none' );
$role !== 'none' AND add_user_to_blog( $blog[ 'blog_id' ], $user_id, $role );
restore_current_blog();
}
}
}
If you want to be nice and give back for receiving help here, you will come back and update my answer with your working solution.