For one of our customers we are currently creating a (mobile) news app which include the blogs of their WP multisite. We made an REST connection between the DB but are stuck at the following problem:

We like to register people to the WP_user table but we have to give them access to 9 sites in total. Is it possible to dump all users in 1 pool to grant access to post comments on all sites?

Thanks in advance,

1 Answer 1



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.

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 ) )

        foreach( $blogs as $key => $blog )
            if ( is_user_member_of_blog( $user_id, $blog[ 'blog_id' ] ) )

            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 );


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.