use woocommerce validation
This commit is contained in:
@@ -9,18 +9,17 @@ class Wiaas_Admin_Profile {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function crf_user_profile_update_errors( $errors, $update, $user ) {
|
public static function crf_user_profile_update_errors( $errors, $update, $user ) {
|
||||||
|
|
||||||
$phone = $_POST['phone'];
|
$phone = $_POST['phone'];
|
||||||
|
|
||||||
if (!preg_match('/^[\d +]*$/', $phone)){
|
if (!WC_Validation::is_phone($phone)){
|
||||||
$errors->add('phone_error', __( '<strong>ERROR</strong>: Enter valid phone number.', 'crf' ));
|
$errors->add('phone_error', __( '<strong>ERROR</strong>: Enter valid phone number.', 'crf' ));
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function modify_user_contact_methods($user_contact){
|
||||||
function modify_user_contact_methods($user_contact){
|
|
||||||
$user_contact['phone'] = __( 'Phone number' );
|
$user_contact['phone'] = __( 'Phone number' );
|
||||||
|
|
||||||
return $user_contact;
|
return $user_contact;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class Wiaas_REST_Customer_API {
|
|||||||
return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('/^[\d +]*$/', $phone)){
|
if (!WC_Validation::is_phone($phone)){
|
||||||
return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user