How to add optional mobile field in registration form
-
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://tinyurl.com/y4mdslwx
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to add optional mobile field in registration form’ is closed to new replies.