Skip to content

Conversation

@reygcalantaol
Copy link
Collaborator

Resolves #406

Description

The issue arises from the condition used to display the wpum_user_roles field. When saving a user, this field is not registered in Carbon Fields, leading to the problem.

Testing Instructions

  1. Enable "Allow Multiple Roles"
  2. Edit any user.
  3. Change or add any role
  4. Hit save

Pre-review Checklist

  • Issue and pull request titles are properly formatted.
  • Acceptance criteria have been satisfied and marked in the related issue.
  • Unit tests are included (if applicable).
  • Self-review of code changes has been completed.
  • Self-review of UX changes has been completed.
  • Review has been requested from @polevaultweb.

@polevaultweb polevaultweb requested a review from Copilot July 5, 2025 14:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() ) {
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() ) {

Copilot uses AI. Check for mistakes.
);

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() ) {
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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() ) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding multiple roles in edit user page is not updating after saving.

2 participants