@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/portfolio/lh-multiple-roles/>
  a sioc:Post ;
  dc:title "Architecture" ;
  dcterms:identifier 151893 ;
  dc:modified "2026-10-20T15:55:48Z"^^xsd:dateTime ;
  dc:created "2026-10-20T15:55:48Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-multiple-roles/architecture/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded "<ul class=\"lh_portfolio-meta\"><li><strong>Part of:</strong> <a href=\"https://lhero.org/portfolio/lh-multiple-roles/\">LH Multiple Roles</a></li></ul><h2 class=\"wp-block-heading\">Buckets</h2><ul class=\"wp-block-list\"><li><strong>Site</strong>: every role not in another bucket. This is WordPress&#8217;s own <code>role</code> select and Role column, so core&#8217;s own checks on <code>user-new.php</code> and <code>user-edit.php</code> keep working.</li><li><strong>Forum</strong>: <code>bbp_get_dynamic_roles()</code>. The select uses bbPress&#8217;s field name <code>bbp-forums-role</code>, so bbPress&#8217;s own handlers save it on edit, add-existing, invitation and signup. This plugin only handles clearing it, because bbPress ignores an empty value.</li><li><strong>Shop</strong>: <code>customer</code> and <code>shop_manager</code>, limited to roles registered on the site. Saved by this plugin.</li></ul><h2 class=\"wp-block-heading\">Keeping roles across set_role()</h2><p class=\"wp-block-paragraph\"><code>WP_User::set_role()</code> removes every role a user holds. <code>keep_bucket_roles()</code> hooks <code>set_user_role</code> and, whenever a site role is set, adds back the forum and shop roles from <code>$old_roles</code>. This covers the Edit User screen, the bulk Change role action and code such as <code>wp_update_user()</code>. Bucket saves that run later (bbPress at <code>profile_update</code> 10, this plugin at 20) still apply the user&#8217;s new choice.</p><h2 class=\"wp-block-heading\">Shop role paths</h2><ul class=\"wp-block-list\"><li>Edit User: <code>profile_update</code> 20.</li><li>Add New User on a single site: <code>user_register</code>.</li><li>Add New User on multisite: <code>signup_user_meta</code> stores the role, and <code>wpmu_activate_user</code> 20 applies it on the signup&#8217;s <code>add_to_blog</code> site.</li><li>Add Existing User: <code>invite_user</code> stores the role in user meta <code>lh_multiple_roles_pending_shop_role_{blog_id}</code>, and <code>added_existing_user</code> applies it, or reads the posted value when no confirmation is needed.</li></ul><h2 class=\"wp-block-heading\">Permissions</h2><p class=\"wp-block-paragraph\">Editing needs <code>promote_user</code> on the target user, and never applies to the editor&#8217;s own account. A shop role is offered only when the current user holds every capability in it. A user&#8217;s current forum or shop role that the editor could not grant is shown disabled and is left unchanged on save.</p><h2 class=\"wp-block-heading\">Admin UI</h2><ul class=\"wp-block-list\"><li>On the user screens (<code>user-edit.php</code>, <code>user-new.php</code>, <code>users.php</code>), <code>editable_roles</code> drops forum and shop roles from the site Role select and from core&#8217;s validation of it.</li><li><code>get_role_list</code> drops them from the Role column.</li><li>Forum role and Shop role columns are inserted after Role.</li><li>bbPress&#8217;s own Forum Role field (<code>BBP_Users_Admin::secondary_role_display</code>, <code>bbp_add_user_form_role_field</code>) and column (<code>user_role_column</code>, <code>user_role_row</code>) are removed on <code>admin_init</code> 100. bbPress&#8217;s bulk forum-role dropdown and row actions are kept.</li></ul><h2 class=\"wp-block-heading\">Filters</h2><ul class=\"wp-block-list\"><li><code>lh_multiple_roles_return_forum_role_slugs</code></li><li><code>lh_multiple_roles_return_shop_role_slugs</code></li><li><code>lh_multiple_roles_return_assignable_shop_roles</code></li><li><code>lh_multiple_roles_init_plugin</code></li></ul>"^^rdf:XMLLiteral ;
  sioc:content "Part of: LH Multiple RolesBucketsSite: every role not in another bucket. This is WordPress&#8217;s own role select and Role column, so core&#8217;s own checks on user-new.php and user-edit.php keep working.Forum: bbp_get_dynamic_roles(). The select uses bbPress&#8217;s field name bbp-forums-role, so bbPress&#8217;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: customer and shop_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&#8217;s new choice.Shop role pathsEdit User: profile_update 20.Add New User on a single site: user_register.Add New User on multisite: signup_user_meta stores the role, and wpmu_activate_user 20 applies it on the signup&#8217;s add_to_blog site.Add Existing User: invite_user stores the role in user meta lh_multiple_roles_pending_shop_role_{blog_id}, and added_existing_user applies it, or reads the posted value when no confirmation is needed.PermissionsEditing needs promote_user on the target user, and never applies to the editor&#8217;s own account. A shop role is offered only when the current user holds every capability in it. A user&#8217;s current forum or shop role that the editor could not grant is shown disabled and is left unchanged on save.Admin UIOn the user screens (user-edit.php, user-new.php, users.php), editable_roles drops forum and shop roles from the site Role select and from core&#8217;s validation of it.get_role_list drops them from the Role column.Forum role and Shop role columns are inserted after Role.bbPress&#8217;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 on admin_init 100. bbPress&#8217;s bulk forum-role dropdown and row actions are kept.Filterslh_multiple_roles_return_forum_role_slugslh_multiple_roles_return_shop_role_slugslh_multiple_roles_return_assignable_shop_roleslh_multiple_roles_init_plugin" ;
  sioc:topic <https://lhero.org/?taxonomy=author&term=cap-1> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
