From b772cb86ee626419a0ec44a00dd25546f8badc31 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 28 Nov 2017 21:21:21 +0200 Subject: [PATCH] - fixed roles fields; --- includes/core/class-fields.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 496c20f2..b1ac87b2 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -2094,7 +2094,7 @@ $field_value = array(); if ( ! empty( $options ) ) { - foreach ($options as $k => $v) { + foreach ( $options as $k => $v ) { $v = rtrim( $v ); @@ -2319,10 +2319,21 @@ $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); $roles = UM()->roles()->get_roles( false, $exclude_roles ); - if ( ! empty( $options ) ) + + if ( ! empty( $options ) ) { + //fix when customers change options for role (radio/dropdown) fields + foreach ( $roles as $role_key => $role_title ) { + if ( false !== $search_key = array_search( $role_title, $options ) ) { + if ( $role_key != $search_key ) { + $options[ $role_key ] = $role_title; + unset( $options[ $search_key ] ); + } + } + } $options = array_intersect( $options, $roles ); - else + } else { $options = $roles; + } return $options; }