How to add Mobile field in Registration form using Theme my login Plugin
I have created a new PHP file in the plugins folder and added the code:
function add_tml_registration_form_fields() {
tml_add_form_field( 'register', 'phone', array(
'type' => 'tel',
'label' => 'Mobile Number',
'value' => tml_get_request_value( 'phone', 'post' ),
'id' => 'phone',
'priority' => 15,) );} add_action( 'init', 'add_tml_registration_form_fields' );
function validate_tml_registration_form_fields( $errors ) { if ( empty( $_POST['phone'] ) ) { $errors->add( 'empty_phone', '<strong>ERROR</strong>: Please enter your mobile number.' ); } add_filter( 'registration_errors', 'validate_tml_registration_form_fields' );
function save_tml_registration_form_fields( $user_id ) { if ( isset( $_POST['phone'] ) ) { update_user_meta( $user_id, 'phone', sanitize_text_field( $_POST['phone'] ) ); } } add_action( 'user_register', 'save_tml_registration_form_fields' );
But I am getting error. please refer to this image: https://www.awesomescreenshot.com/image/5706632/f5c513616090709c1ee6faa42bc6afeb
Please suggest some help.
Leave an answer
You must login or register to add a new answer .