From f6e585773efd6a4c6b937bebfa0b94b271a86bde Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Mon, 19 Dec 2016 23:40:35 +0800 Subject: [PATCH] Adds new string validation filter hooks - um_validation_safe_username_regex - um_validation_safe_string_regex --- core/um-validation.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/um-validation.php b/core/um-validation.php index 638f2928..04c3cdba 100644 --- a/core/um-validation.php +++ b/core/um-validation.php @@ -53,9 +53,12 @@ class UM_Validation { *** @space, dash, underscore ***/ function safe_username( $string ) { + + $regex_safe_username = apply_filter('um_validation_safe_username_regex',$this->regex_safe ); + if ( is_email( $string ) ) return true; - if ( !is_email( $string) && !preg_match( $this->regex_safe, $string ) ) + if ( !is_email( $string) && !preg_match( $regex_safe_username, $string ) ) return false; return true; } @@ -64,8 +67,12 @@ class UM_Validation { *** @dash and underscore (metakey) ***/ function safe_string($string){ - if ( !preg_match( $this->regex_safe, $string) ) + + $regex_safe_string = apply_filter('um_validation_safe_string_regex',$this->regex_safe ); + + if ( !preg_match( $regex_safe_string, $string) ){ return false; + } return true; }