Architecture

Buckets

Keeping roles across set_role()

WP_User::set_role() removes every role a user holds. keep_bucket_roles() hooks set_user_role and, whenever a site role is set, adds back the forum and shop roles from $old_roles. This covers the Edit User screen, the bulk Change role action and code such as wp_update_user(). Bucket saves that run later (bbPress at profile_update 10, this plugin at 20) still apply the user’s new choice.

Shop role paths

Permissions

Editing needs promote_user on the target user, and never applies to the editor’s own account. A shop role is offered only when the current user holds every capability in it. A user’s current forum or shop role that the editor could not grant is shown disabled and is left unchanged on save.

Admin UI

Filters