User Role Sync

This add-on copies the users, and their roles, from a source blog to other blogs in the network.

Screenshots

Notes

Users are added, and their roles set to the same as the original blog, on each child blog.

Users are not removed from the child blog.

The sync can be called programmatically:

broadcast_user_role_sync()->sync_user_roles( [ 'blogs' => 82 ] );

The call takes other options also:

  • exclude is an array of user IDs to exclude
  • include is an array of user IDs to include
  • role__in is an array of role slugs that the returned users must have
  • role__not_in is an array of role slugs that the returned users may not have

Where to buy

This add-on is a part of the following packs:

Comments

  1. Love your plugin. I have been attempting to programattically sync users with specific roles. However, I have not been able to accomplish this.

    Any suggestions on how to use “broadcast_user_role_sync()->sync_user_roles( [ ‘blogs’ => 82 ] );” with role_in = “clinician_utah”

    I am assuming that 82 in the code above is the blog ID?

    Any guidance would be much appreciated :-)

    1. Blogs = to which blogs to send the user roles from the current blog.

      So in your case, I’m figuring you’re looking for something like this:

      broadcast_user_role_sync()->sync_user_roles( [
      ‘blogs’ => 82,
      ‘role__in’ => ‘clinician_utah’,
      ] );

      Don’t forget the double underscore in role__in, which I kept to stay with the WordPress “standard”.

Leave a Reply

Your email address will not be published. Required fields are marked *