How to modify deafult fields specifically on front-end User Registration Form
Support › MB User Profile › How to modify deafult fields specifically on front-end User Registration FormResolved
- This topic has 5 replies, 2 voices, and was last updated 2 years, 10 months ago by
John Rood.
-
AuthorPosts
-
June 28, 2022 at 4:53 AM #36692
John Rood
ParticipantIs this even possible? I'm trying to modify the fields that are included with the default fields group that loads when you use the registration form shortcode. I'd like to do this in MB builder if possible, but code is OK too. Basically I'm trying to add the default WP First and Last name fields in with that first group that already has username, password, email, etc. so that it's all together.
June 28, 2022 at 5:16 PM #36698Long Nguyen
ModeratorHi John,
There is no option to add a custom field to the registration form in the builder. With coding, you can follow these topics to know how to modify the registration form by using the filter hook
rwmb_profile_register_fields
https://support.metabox.io/topic/mb_user_profile_register-autocompletenew-password/
https://support.metabox.io/topic/duplicated-register-formsJune 29, 2022 at 2:19 AM #36702John Rood
ParticipantThis is extremely helpful, thank you!
June 29, 2022 at 4:57 AM #36704John Rood
ParticipantOkay, follow up question:
I have followed the examples you shared, and ended up with the resulting code:
//adapted from: https://support.metabox.io/topic/mb_user_profile_register-autocompletenew-password/ //relevant docs: https://docs.metabox.io/extensions/mb-user-profile/#form-fields-filters function add_more_registration_fields( $fields ) { $fields = [ 'first_name' =>[ 'id' => 'first_name', // THIS 'name' => 'First Name', 'type' => 'text', 'required' => true, 'columns' => 4, ], 'last_name' =>[ 'id' => 'last_name', // THIS 'name' => 'Last Name', 'type' => 'text', 'required' => true, 'columns' => 4, ], 'username' => [ 'name' => __( 'Username', 'mb-user-profile' ), 'id' => 'user_login', 'type' => 'text', 'required' => true, 'columns' => 4, ], 'email' => [ 'name' => __( 'Email', 'mb-user-profile' ), 'id' => 'user_email', 'type' => 'email', 'required' => true, 'columns' => 6, 'desc' => 'Used for notifications and alerts (if opted-in).', ], 'phonenumber' => [ 'name' => __( 'Phone Number', 'mb-user-profile' ), 'id' => 'phonenumber', 'type' => 'tel', 'required' => true, 'desc' => 'Used for notifications and alerts (if opted-in).', 'columns' => 6, ], 'password' => [ 'name' => __( 'Password', 'mb-user-profile' ), 'id' => 'user_pass', 'type' => 'password', 'required' => true, 'columns' => 6, 'desc' => '<span id="password-strength" class="rwmb-password-strength"></span>', 'attributes' => [ 'autocomplete' => 'new-password' ] ], 'password2' => [ 'name' => __( 'Confirm Password', 'mb-user-profile' ), 'id' => 'user_pass2', 'type' => 'password', 'required' => true, 'columns' => 6, ], // ... add more fields here ]; return $fields; } add_filter( 'rwmb_profile_register_fields', 'add_more_registration_fields' );
Everything works except the first 2 fields. The first and last name do not get copied into the user meta. I am following the instructions listed here: https://docs.metabox.io/extensions/mb-user-profile/#edit-default-fields. The IDs match. Is there something else I'm doing wrong?
June 29, 2022 at 1:27 PM #36707Long Nguyen
ModeratorHi John,
It looks like the registration form does not process other custom fields in the default meta box
rwmb-user-register
. You will need to add another meta box (field group) and follow the documentation "edit default fields" to add the first name and last name of the new user.
The filter will help you to modify the field settings of default fields. I will inform the development team to consider supporting this case in future updates.Thank you.
June 29, 2022 at 10:27 PM #36723John Rood
ParticipantThank you, that will work for now. It would be helpful to have this functionality in the future, as it would allow the actual set of default fields to be ordered alongside the others in the registration form.
-
AuthorPosts
- You must be logged in to reply to this topic.