add phone number field
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Wiaas_Admin_Profile {
|
||||
|
||||
public static function init() {
|
||||
add_filter( 'user_contactmethods', array(__CLASS__, 'modify_user_contact_methods') );
|
||||
|
||||
add_action( 'user_profile_update_errors', array(__CLASS__, 'crf_user_profile_update_errors'), 10, 3 );
|
||||
|
||||
}
|
||||
|
||||
function crf_user_profile_update_errors( $errors, $update, $user ) {
|
||||
|
||||
$phone = $_POST['phone'];
|
||||
|
||||
if (!preg_match('/^[\d +]*$/', $phone)){
|
||||
$errors->add('phone_error', __( '<strong>ERROR</strong>: Enter valid phone number.', 'crf' ));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
function modify_user_contact_methods($user_contact){
|
||||
$user_contact['phone'] = __( 'Phone number' );
|
||||
|
||||
return $user_contact;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Wiaas_Admin_Profile::init();
|
||||
@@ -28,6 +28,8 @@ class Wiaas_Admin {
|
||||
|
||||
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-supplier.php';
|
||||
|
||||
require_once dirname(__FILE__) . '/admin/class-wiaas-admin-user-profile.php';
|
||||
|
||||
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user