There is a website on wordpress and a registration form in which (a required field) I want to get the user login by last name without displaying this field on the screen. To do this, I place the value displayed in the value of the last name in the field, but this option only works when you press the submit button again (for the first time, an error pops up, which swears at the unfilled required login field). How to fix this moment?
<form name="registerform" class="registerform" id="registerform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'register' ); ?>" method="post"> <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 class="submit"> <input type="hidden" name="user_login" id="user_login<?php $template->the_instance(); ?>" value="<?php $template->the_posted_value( 'last_name' ); ?>" class="regular-text" /> <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Register', 'theme-my-login' ); ?>" /> <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'register' ); ?>" /> <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" /> <input type="hidden" name="action" value="register" /> </p> </form>