Buckets
- Site: every role not in another bucket. This is WordPress’s own
roleselect and Role column, so core’s own checks onuser-new.phpanduser-edit.phpkeep working. - Forum:
bbp_get_dynamic_roles(). The select uses bbPress’s field namebbp-forums-role, so bbPress’s own handlers save it on edit, add-existing, invitation and signup. This plugin only handles clearing it, because bbPress ignores an empty value. - Shop:
customerandshop_manager, limited to roles registered on the site. Saved by this plugin.
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
- Edit User:
profile_update20. - Add New User on a single site:
user_register. - Add New User on multisite:
signup_user_metastores the role, andwpmu_activate_user20 applies it on the signup’sadd_to_blogsite. - Add Existing User:
invite_userstores the role in user metalh_multiple_roles_pending_shop_role_{blog_id}, andadded_existing_userapplies it, or reads the posted value when no confirmation is needed.
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
- On the user screens (
user-edit.php,user-new.php,users.php),editable_rolesdrops forum and shop roles from the site Role select and from core’s validation of it. get_role_listdrops them from the Role column.- Forum role and Shop role columns are inserted after Role.
- bbPress’s own Forum Role field (
BBP_Users_Admin::secondary_role_display,bbp_add_user_form_role_field) and column (user_role_column,user_role_row) are removed onadmin_init100. bbPress’s bulk forum-role dropdown and row actions are kept.
Filters
lh_multiple_roles_return_forum_role_slugslh_multiple_roles_return_shop_role_slugslh_multiple_roles_return_assignable_shop_roleslh_multiple_roles_init_plugin