Login/Registration page
Quote from Jhonathan on August 29, 2023, 3:30 pmHow could I add more fields on the registration screen for the user to fill in?
I wouldn’t want to use that default wordpress screen, would there be a way to do this using a plugin?
How could I add more fields on the registration screen for the user to fill in?
I wouldn’t want to use that default wordpress screen, would there be a way to do this using a plugin?
Quote from newforum.top on August 30, 2023, 7:30 amКак я могу добавить больше полей на экране регистрации, чтобы пользователь мог их заполнить?
Я бы не хотел использовать этот экран WordPress по умолчанию, есть ли способ сделать это с помощью плагина?
Also interested in this question
Как я могу добавить больше полей на экране регистрации, чтобы пользователь мог их заполнить?
Я бы не хотел использовать этот экран WordPress по умолчанию, есть ли способ сделать это с помощью плагина?
Also interested in this question
Quote from Jim on September 3, 2023, 12:46 amI added two fields (given name and family name) in functions.php with the following code:
/* * WP Registration form, require first and last name * and set nickname and display_name to 'first last' */ //1. Create additional fields add_action( 'register_form', 'fp_register_form' ); function fp_register_form() { $first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : ''; $last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : ''; ?> <p> <label for="first_name"><?php _e( 'Given Name', 'mydomain' ) ?><br /> <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label> </p> <p> <label for="last_name"><?php _e( 'Surname', 'mydomain' ) ?><br /> <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label> </p> <?php } //2. Add validation. first_name and last_name are required. add_filter( 'registration_errors', 'fp_registration_errors', 10, 3 ); function fp_registration_errors( $errors, $sanitized_user_login, $user_email ) { if ( empty( $_POST['first_name'] ) || ! empty( $_POST['first_name'] ) && trim( $_POST['first_name'] ) == '' ) { $errors->add( 'first_name_error', '<strong>Error</strong>: You must enter your given (first) name.' ); } if ( empty( $_POST['last_name'] ) || ! empty( $_POST['last_name'] ) && trim( $_POST['last_name'] ) == '' ) { $errors->add( 'last_name_error', '<strong>Error</strong>: You must enter your surname (last name).' ); } return $errors; } //3. Save our extra registration user data. 'user_register' fires after registration. add_action( 'user_register', 'fp_user_register' ); function fp_user_register( $user_id ) { $first = trim( $_POST['first_name'] ); $last = trim( $_POST['last_name'] ); $compound = $first . ' ' . $last; update_user_meta( $user_id, 'first_name', $first ); update_user_meta( $user_id, 'last_name', $last ); update_user_meta( $user_id, 'nickname', $compound ); wp_update_user( array( 'ID' => $user_id, 'display_name' => $compound ) ); }It looks like in the attached image.
I added two fields (given name and family name) in functions.php with the following code:
/* * WP Registration form, require first and last name * and set nickname and display_name to 'first last' */ //1. Create additional fields add_action( 'register_form', 'fp_register_form' ); function fp_register_form() { $first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : ''; $last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : ''; ?> <p> <label for="first_name"><?php _e( 'Given Name', 'mydomain' ) ?><br /> <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label> </p> <p> <label for="last_name"><?php _e( 'Surname', 'mydomain' ) ?><br /> <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label> </p> <?php } //2. Add validation. first_name and last_name are required. add_filter( 'registration_errors', 'fp_registration_errors', 10, 3 ); function fp_registration_errors( $errors, $sanitized_user_login, $user_email ) { if ( empty( $_POST['first_name'] ) || ! empty( $_POST['first_name'] ) && trim( $_POST['first_name'] ) == '' ) { $errors->add( 'first_name_error', '<strong>Error</strong>: You must enter your given (first) name.' ); } if ( empty( $_POST['last_name'] ) || ! empty( $_POST['last_name'] ) && trim( $_POST['last_name'] ) == '' ) { $errors->add( 'last_name_error', '<strong>Error</strong>: You must enter your surname (last name).' ); } return $errors; } //3. Save our extra registration user data. 'user_register' fires after registration. add_action( 'user_register', 'fp_user_register' ); function fp_user_register( $user_id ) { $first = trim( $_POST['first_name'] ); $last = trim( $_POST['last_name'] ); $compound = $first . ' ' . $last; update_user_meta( $user_id, 'first_name', $first ); update_user_meta( $user_id, 'last_name', $last ); update_user_meta( $user_id, 'nickname', $compound ); wp_update_user( array( 'ID' => $user_id, 'display_name' => $compound ) ); }
It looks like in the attached image.
Uploaded files:
Quote from Jhonathan on September 15, 2023, 10:08 pmI found a solution
I used this plugin to create the fields I would like to add and changed the url to access the registration page.
https://themegrill.com/blog/add-custom-fields-in-user-registration-wordpress/
in functions.php I added this code.
add_filter(‘register_url’, ‘my_register_url’);function my_register_url($register_url) {return home_url(‘/cadastrar’);}Thank you for your help
I found a solution
I used this plugin to create the fields I would like to add and changed the url to access the registration page.
How to Add Custom Fields in WordPress User Registration Form? (Easy Tutorial 2022)
in functions.php I added this code.