Thanks Jeff,
It doesn’t run.
When I go to the register page, I don’t see the added fields
https://flammesjumelles.world/register/
1 –
I add this code into the register-form.php file (between <form> and </form>) that is into the root of my child theme (into the main theme it’s the same – it doesn’t run).
———- code ———-
<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>
2 – And I have theme-my-login-custom.php file into the root of plugins folder with this single code :
——– code ———
<?php
function tml_registration_errors( $errors ) {
if ( empty( $_POST[‘first_name’] ) )
$errors->add( ’empty_first_name’, ‘ERROR: Please enter your first name.’ );
if ( empty( $_POST[‘last_name’] ) )
$errors->add( ’empty_last_name’, ‘ERROR: Please enter your last name.’ );
return $errors;
}
add_filter( ‘registration_errors’, ‘tml_registration_errors’ );
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’ );
?>
———- Info ———
I use multisite and WP 4.6
Thanks for your help.
Ludovic