admin管理员组

文章数量:1314488

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:

Please suggest some help.

本文标签: How to add Mobile field in Registration form using Theme my login Plugin