From ce73840ce2c34e798659418cbe58eafc5bd0b24c Mon Sep 17 00:00:00 2001 From: yuriinalivaiko Date: Tue, 23 Mar 2021 14:48:42 +0200 Subject: [PATCH] Fixed: default value with comma for checkbox --- includes/core/class-fields.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 56e94af2..cd934b5c 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -1045,9 +1045,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) { if ( ! $this->editing || 'custom' == $this->set_mode ) { // show default on register screen if there is default if ( isset( $data['default'] ) ) { - if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) { - $data['default'] = explode( ', ', $data['default'] ); - } if ( ! is_array( $data['default'] ) && $data['default'] === $value ) { return true; @@ -1061,6 +1058,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) { return true; } + // default value with comma + if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) { + $choices = array_map( 'trim', explode( ',', $data['default'] ) ); + if( in_array( $value, $choices ) ){ + return true; + } + } + } } else {