User Role Sync

This add-on for Broadcast manipulates users:

  • copies users between blogs
  • copies roles between blogs
  • removes users from blogs

The roles are overwritten on each target blog. If you use a role editing plugin, you can use this tool to sync the role capabilities to the other blogs in the network.

When syncing users, the user’s image from the One User Avatar plugin is copied.

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:

  • include is an array of user IDs to sync
  • role__in is an array of role slugs to sync

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”.

  2. Hello,

    So this addon will automatically sync users when they register? Or i need to code something?

    1. The add-on does not automatically sync users when they register, although I suppose a code snippet could do that. If you e-mail me your requirements (when to sync, to where) I can perhaps come up with something that triggers the User Role Sync add-on?

Leave a Reply to Alexander Cancel reply

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