Repository navigation
Fix: Refresh WorkOS memberships and roles during manual re-sync - #93
Merged
Merged
Conversation
defunctl
marked this pull request as ready for review
October 27, 2026 18:06
Owner
Before93-resync-before.mp4After93-resync-after.mp493-bulk-roles-after.mp4 |
bordoni
approved these changes
Oct 28, 2026
Fix re-sync return to searched and filtered Users lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main Changes
Administrators cannot currently repair stale WorkOS membership roles through the Users screen. Re-sync from WorkOS refreshes profile fields only, while Sync Roles from WorkOS reapplies the locally stored role. If a role-change webhook was missed, both actions can leave WordPress using the wrong role.
Both actions now fetch the user's current membership for the configured WorkOS organization. For example, a user changed from Admin to Member in WorkOS can be refreshed from WordPress administrator to subscriber using the configured role mapping, without waiting for another webhook.
What changes
member.UserSync, which receivesMembershipSyncand the API client through constructors.MembershipSynccoordinates injectedMembershipReader,OrganizationResolver,MembershipState, andMembershipWriterobjects using an immutableMembershipSnapshot.Failure handling
API failures, missing/inactive or ambiguous memberships, and unmapped roles return errors without assigning a fallback role. Missing or inactive membership is reported for review, not treated as an instruction to deprovision. The saved membership, mapped WordPress role, and applied membership timestamp are verified before reporting success; unresolved extra WordPress roles are reported rather than silently counted as synced. A later failure can leave earlier membership or role writes applied, so an error does not imply that every change was rolled back.
Use it
On Users, click Re-sync from WorkOS under a linked user's WorkOS ID. For several users, select them and choose Re-sync from WorkOS or Sync Roles from WorkOS from Bulk actions.
With WP-CLI and the plugin configured, the same full refresh is available below. Replace
42with the linked WordPress user's ID:Validation
workos user syncandworkos sync pullloaded successfully. An admin-context bootstrap check confirmed exactly one shared UserSync and RoleMapper hook registration.The existing webhook handlers and manual refresh are not serialized by a shared lock; these checks do not provide atomic ordering across simultaneous writers.
This provides manual repair when automatic delivery was missed. Each environment still needs its own correctly configured WorkOS webhook endpoint and signing secret.