Fix: Adding multiple roles in edit user page is not updating after saving#407
Open
reygcalantaol wants to merge 3 commits intodevelopfrom
Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the multiple roles selector not appearing on the user edit page by updating the page-check condition to include user-edit.php.
- Expanded the conditional to show the roles multiselect on both user creation and edit pages.
- Ensured network admin screens are still excluded.
| ); | ||
|
|
||
| if ( $allow_multiple_roles && ( $profileuser || 'user-new.php' === $pagenow ) && ! is_network_admin() ) { | ||
| if ( $allow_multiple_roles && ( $profileuser || in_array( $pagenow, array( 'user-new.php', 'user-edit.php' ) ) ) && ! is_network_admin() ) { |
There was a problem hiding this comment.
Consider using the strict parameter in in_array (e.g., in_array($pagenow, ['user-new.php', 'user-edit.php'], true)) to ensure type-safe comparisons.
Suggested change
| if ( $allow_multiple_roles && ( $profileuser || in_array( $pagenow, array( 'user-new.php', 'user-edit.php' ) ) ) && ! is_network_admin() ) { | |
| if ( $allow_multiple_roles && ( $profileuser || in_array( $pagenow, array( 'user-new.php', 'user-edit.php' ), true ) ) && ! is_network_admin() ) { |
| ); | ||
|
|
||
| if ( $allow_multiple_roles && ( $profileuser || 'user-new.php' === $pagenow ) && ! is_network_admin() ) { | ||
| if ( $allow_multiple_roles && ( $profileuser || in_array( $pagenow, array( 'user-new.php', 'user-edit.php' ) ) ) && ! is_network_admin() ) { |
There was a problem hiding this comment.
[nitpick] Extract the array of page names into a descriptive variable or constant (e.g., $role_pages = ['user-new.php', 'user-edit.php'];) to improve readability and simplify future updates.
Suggested change
| if ( $allow_multiple_roles && ( $profileuser || in_array( $pagenow, array( 'user-new.php', 'user-edit.php' ) ) ) && ! is_network_admin() ) { | |
| $role_pages = array( 'user-new.php', 'user-edit.php' ); | |
| if ( $allow_multiple_roles && ( $profileuser || in_array( $pagenow, $role_pages ) ) && ! is_network_admin() ) { |
…ge-is-not-updating-after-saving-
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Resolves #406
Summary
Fixes the multiple roles field not appearing on the Edit User page (
user-edit.php). Thewpum_user_rolesCarbon Field was only registered when$pagenow === 'user-new.php', so editing an existing user's roles silently failed.Fix: Change
'user-new.php' === $pagenowtoin_array( $pagenow, array( 'user-new.php', 'user-edit.php' ) ).Manual Test Plan
Prerequisites
1. Verify roles field appears on Edit User
2. Add a role and save
3. Remove a role and save
4. Verify Add New User still works
5. Verify disabled state
WPUnit Test Coverage
11 tests in
tests/wpunit/Privacy/MultipleRolesFieldTest.php:carbon_fields_register_fieldsuser-edit.phpanduser-new.phpin_arraycondition passes for both pages (the core fix)$profileuserset🤖 Generated with Claude Code