diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index efd7884c..d34bf313 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -849,8 +849,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) { // normal state if ( isset( UM()->form()->post_form[ $key ] ) ) { - //show empty value for password fields - if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) { + // Show empty value for password fields. + if ( 'password' !== $this->set_mode && false !== strpos( $key, 'user_pass' ) ) { return ''; } @@ -862,10 +862,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) { return stripslashes_deep( UM()->form()->post_form[ $key ] ); - } elseif ( um_user( $key ) && true === $this->editing ) { + } elseif ( true === $this->editing && um_user( $key ) ) { - //show empty value for password fields - if ( strstr( $key, 'user_pass' ) || $type == 'password' ) { + // Show empty value for password fields. + if ( 'password' === $type || false !== strpos( $key, 'user_pass' ) ) { return ''; } @@ -915,7 +915,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { */ $value = apply_filters( "um_edit_{$type}_field_value", $value, $key ); - } elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && true === $this->viewing ) { + } elseif ( true === $this->viewing && ( um_user( $key ) || isset( $data['show_anyway'] ) ) ) { return um_filtered_value( $key, $data ); @@ -4432,7 +4432,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"'; } - if ( empty( $res ) ) { + if ( empty( $res ) && ! ( 'number' === $type && '' !== $res ) ) { $output = ''; } else { $output .= '
'; diff --git a/includes/core/class-form.php b/includes/core/class-form.php index ea331c34..1d4168db 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -752,7 +752,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { $form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field ); break; case 'number': - $form[ $k ] = (int) $form[ $k ]; + $form[ $k ] = '' !== $form[ $k ] ? (int) $form[ $k ] : ''; break; case 'textarea': if ( ! empty( $field['html'] ) || ( UM()->profile()->get_show_bio_key( $form ) === $k && UM()->options()->get( 'profile_show_html_bio' ) ) ) { diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php index 69362abe..1cbf29e5 100644 --- a/includes/core/um-actions-form.php +++ b/includes/core/um-actions-form.php @@ -514,7 +514,7 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) { } // Validate the Required condition for the Number field. Set the Minimum Number option to allow 0 value. - if ( isset( $array['type'] ) && 'number' === $array['type'] && ! isset( $array['min'] ) && ! empty( $array['required'] ) && empty( $submitted_data[ $key ] ) ) { + if ( isset( $array['type'] ) && 'number' === $array['type'] && ! empty( $array['required'] ) && '' === $submitted_data[ $key ] ) { // translators: %s: title. UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) ); }