On the website with the wordpress engine and the Theme My Logi n plugin installed, I want to add the following fields to the registration template to the existing fields (login, password, e-mail) (Last Name, First Name, Mobile Phone, gender), but the problem is that these fields in the database does not save .. How to add them correctly?

 <p><input type="text" name="user_login" id="user_login<?php $template->the_instance(); ?>" value="<?php $template->the_posted_value( 'user_login' ); ?>" class="regular-text" /></p> <p><label for="last_name<?php $template->the_instance(); ?>">Ѐамилия:<span class="necessarily">*</span></label><input type="text" name="last_name" id="last_name<?php $template->the_instance(); ?>" class="regular-text" value="<?php $template->the_posted_value( 'last_name' ); ?>" /></p> <p><label for="first_name<?php $template->the_instance(); ?>">Имя:<span class="necessarily">*</span></label><input type="text" name="first_name" id="first_name<?php $template->the_instance(); ?>" class="regular-text" value="<?php $template->the_posted_value( 'first_name' ); ?>" /></p> <?php $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ); if ( $show_password_fields ) : ?> <div id="password"> <p><label for="pass1">ΠŸΠ°Ρ€ΠΎΠ»ΡŒ:<span class="necessarily">*</span></label><input type="password" name="pass1" id="pass1" size="16" autocomplete="off" /></p> <p><label for="pass2">ΠŸΠΎΠ²Ρ‚ΠΎΡ€ΠΈΡ‚ΡŒ ΠΏΠ°Ρ€ΠΎΠ»ΡŒ:<span class="necessarily">*</span></label><input type="password" name="pass2" id="pass2" size="16" autocomplete="off" /></p> </div> <?php endif; ?> <p><label for="user_email">E-mail:<span class="necessarily">*</span></label><input type="email" name="user_email" id="user_email<?php $template->the_instance(); ?>" value="<?php $template->the_posted_value( 'user_email' ); ?>" class="regular-text" /></p> <p><label for="user_tel">ΠœΠΎΠ±ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½:<span class="necessarily">*</span></label><input type="tel" name="tel_number" pattern=".{7,}" id="tel_number<?php $template->the_instance(); ?>" value="<?php $template->the_posted_value( 'tel_number' ); ?>" class="regular-text" size="20" /></p> <p class="form-row form-row-last"> <label for="user_gender">Пол:</label> <input type="radio" name="gender" value="муТской" <?php checked('муТской', get_user_meta($profileuser->ID, 'gender', true)); ?>>муТской <input type="radio" name="gender" value="ТСнский" <?php checked('ТСнский', get_user_meta($profileuser->ID, 'gender', true)); ?>>ТСнский </p> 

    1 answer 1

    So - the answer is here : add new fields to the topic

     <p> <label for="first_name<?php $template->the_instance(); ?>"><?php _e( 'First name', 'theme-my-login' ) ?></label> <input type="text" name="first_name" id="first_name<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'first_name' ); ?>" size="20" tabindex="20" /> </p> <p> <label for="last_name<?php $template->the_instance(); ?>"><?php _e( 'Last name', 'theme-my-login' ) ?></label> <input type="text" name="last_name" id="last_name<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'last_name' ); ?>" size="20" tabindex="20" /> </p> 

    we carry out validation:

     function tml_registration_errors( $errors ) { if ( empty( $_POST['first_name'] ) ) $errors->add( 'empty_first_name', '<strong>ERROR</strong>: Please enter your first name.' ); if ( empty( $_POST['last_name'] ) ) $errors->add( 'empty_last_name', '<strong>ERROR</strong>: Please enter your last name.' ); return $errors; } add_filter( 'registration_errors', 'tml_registration_errors' ); 

    save the fields:

     function tml_user_register( $user_id ) { if ( !empty( $_POST['first_name'] ) ) update_user_meta( $user_id, 'first_name', $_POST['first_name'] ); if ( !empty( $_POST['last_name'] ) ) update_user_meta( $user_id, 'last_name', $_POST['last_name'] ); } add_action( 'user_register', 'tml_user_register' );