Hello!
WPRUS synchronises the roles when the following WordPress actions are triggered (registered in Wprus_Api_Update
and calling Wprus_Api_Role::handle_notify_remote_data( $data, $site, $user )
):
add_action( 'profile_update', array( $this, 'track_updates' ), PHP_INT_MAX - 100, 1 );
add_action( 'add_user_role', array( $this, 'track_updates' ), PHP_INT_MAX - 100, 1 );
add_action( 'remove_user_role', array( $this, 'track_updates' ), PHP_INT_MAX - 100, 1 );
add_action( 'set_user_role', array( $this, 'track_updates' ), PHP_INT_MAX - 100, 1 );
add_action( 'wp_update_user', array( $this, 'track_updates' ), PHP_INT_MAX - 100, 1 );
So, for the synchronization to happen, one of these actions must be called via do_action
somewhere in your code, either directly or by the code you are using. Which one is the most appropriate depends on your script’s logic and is out the scope of this support forum.
However, it seems the task performed by your update script is either a one-time task, or a recurring batch operation.
While triggering one of the WordPress actions above would work in theory, running the sync for 200+ users would fire an equal number of requests, all at once. WPRUS is designed to process sync per user and in real time; this is not designed to scale for batch user operations, so it may not be ideal, and your experience may vary.
If this is a one-time operation, I would recommend to run part of your update script on the other site instead of relying on sync. I know this is a bit out of scope, and won’t go into implementation details, but you could collect the $username
of the users you updated on siteA during the process, save it somewhere, and then feed it to a similar user role update logic on siteB after retrieving the corresponding $user_id
.