From d26de2a85caea08cc36bb109feab0c152b5934f8 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Tue, 6 Feb 2024 15:19:33 +0200 Subject: [PATCH] - add alpha_numeric validation to fields --- includes/core/um-actions-form.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php index 51b2b4a4..259ac140 100644 --- a/includes/core/um-actions-form.php +++ b/includes/core/um-actions-form.php @@ -987,6 +987,14 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) { } break; + case 'alpha_numeric': + if ( '' !== $submitted_data[ $key ] ) { + if ( ! preg_match( '/^[\p{L}0-9\s]+$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) { + UM()->form()->add_error( $key, __( 'You must provide alphabetic letters or numbers', 'ultimate-member' ) ); + } + } + break; + case 'lowercase': if ( '' !== $submitted_data[ $key ] ) { if ( ! ctype_lower( str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {