Sort the username and email fields
Support › MB User Meta › Sort the username and email fieldsResolved
- This topic has 10 replies, 2 voices, and was last updated 4 years ago by
Long Nguyen.
-
AuthorPosts
-
March 8, 2021 at 9:48 AM #24763
[email protected]
ParticipantHello, I am follow the next guide to build a Custom Register Page:
https://metabox.io/create-wordpress-custom-user-profile-page-in-frontend/I am using the next shortcode
[mb_user_profile_register id="usuarios-campos-personalizados" label_submit="Register" confirmation="Your account has been created successfully!"]
So I get the custom personal register form but the form show the default fielsd (Username, Email, Password, Confirm password) in first place. Please see the image:
https://i.imgur.com/kzqRwTc.pngHowever I want sort my form in different order, for example:
First name
Last name
Email address
other_custom_field
Username
Password
Confirm passwordHow can I get it? is possible
Thank you in advanced!
March 8, 2021 at 12:29 PM #24766Long Nguyen
ModeratorHi,
You can follow Johannes's reply to customize the registration form https://support.metabox.io/topic/registration-username-as-email-duplicated-fields-avatar-visibility-issue/page/2/#post-21465.
function add_more_registration_fields( $fields ) { $fields = [ 'first_name' => [ 'name' => 'First Name', 'id' => 'first_name', 'type' => 'text', 'required' => 1 ], 'last_name' => [ 'name' => 'Last Name', 'id' => 'last_name', 'type' => 'text', 'required' => 1 ], 'username' => [ 'name' => __( 'Username', 'mb-user-profile' ), 'id' => 'user_login', 'type' => 'text', 'required' => true, ], 'email' => [ 'name' => __( 'Email', 'mb-user-profile' ), 'id' => 'user_email', 'type' => 'email', 'required' => true, ], 'password' => [ 'name' => __( 'Password', 'mb-user-profile' ), 'id' => 'user_pass', 'type' => 'password', 'required' => true, 'desc' => '<span id="password-strength" class="rwmb-password-strength"></span>', ], 'password2' => [ 'name' => __( 'Confirm Password', 'mb-user-profile' ), 'id' => 'user_pass2', 'type' => 'password', 'required' => true, ], // ... add more fields here ]; return $fields; } add_filter( 'rwmb_profile_register_fields', 'add_more_registration_fields' );
Get more form filters here https://docs.metabox.io/extensions/mb-user-profile/#form-fields-filters. They are located in the file
wp-content/plugins/mb-user-profile/src/DefaultFields.php
.March 12, 2021 at 4:29 AM #24852[email protected]
ParticipantSorry but I don't understand. I added it code in my functions.php and i didn't get nothing. What should I do?
March 12, 2021 at 10:50 AM #24861Long Nguyen
ModeratorHi,
Please check the file functions.php in the activated theme. Or you can use the plugin Code Snippets to run the code https://wordpress.org/plugins/code-snippets/.
March 13, 2021 at 3:00 AM #24890[email protected]
ParticipantHello, I did it but it doesn't work correctly:
- With this solution I can't have differents register forms, For example I can't have one form with one sort and other form with other sort Is it possible?
- No is possible change the lables for Password and Username fields, please see the next image:
https://imgur.com/gQAwCk4
https://imgur.com/a/sKpEzYp - With this approach can I use "Custom table extension" Can you explainme please?
- In this post:
Ahn said "and will do for User Profile next." I had hoping that User profile will work equal to "Frontend Submission extension"
Do you think that in sometime Anh retake this extension?
March 14, 2021 at 3:00 PM #24906Long Nguyen
ModeratorHi,
Did you require/include the file "custom-functions/functiones.php" in the main file functions.php of the "astra-child" theme?
You can add the code to the file functions.php, screenshot https://share.getcloudapp.com/5zuA6xGb
or just use the plugin Code Snippets to see it works.March 15, 2021 at 12:03 AM #24908[email protected]
Participant295 / 5000
Resultados de traducción
Hello, I really appreciate your answer. But you haven't really answered any of my questions.I want to think that it is because my English is very bad and at some point you have not understood me.
I am using the file "functions.php" because in the file "functions.php" I wrote the following lines:
require_once('custom-functions/funciones.php');
You can see it:
https://imgur.com/3Wo1xwfNow you can see that my code is working and none of my questions were aimed at telling you that the Hook you provided was not working. On the contrary, this works but I asked you 3 specific questions. I did not receive any response. Can you solve them please? If because of my poor English you don't understand something, why don't you tell me and I'll try to explain it better
March 15, 2021 at 12:26 PM #24916Long Nguyen
ModeratorHi,
Sorry if I misunderstood your questions. I will try to reply sequently.
- If you use the filter to modify the register form, you can only use the fields in the code as default fields and add more fields by adding the attribute
id="meta-box-id"
to the shortcode to create different forms. - Please try again with this code (remove the array key)
- No, because we use the filter to modify the field settings while the custom table needs the meta box settings. Read more on the documentation https://docs.metabox.io/extensions/mb-custom-table/#using-custom-tables.
- I will inform the Keymaster to take a look at that case.
function add_more_registration_fields( $fields ) { $fields = [ [ 'name' => __( 'Email', 'mb-user-profile' ), 'id' => 'user_email', 'type' => 'email', 'required' => true, ], [ 'name' => __( 'Password123', 'mb-user-profile' ), 'id' => 'user_pass', 'type' => 'password', 'required' => true, 'desc' => '<span id="password-strength" class="rwmb-password-strength"></span>', ], [ 'name' => __( 'Confirm Password123', 'mb-user-profile' ), 'id' => 'user_pass2', 'type' => 'password', 'required' => true, ], // ... add more fields here ]; return $fields; }
March 19, 2021 at 10:25 AM #26518[email protected]
ParticipantHello now it is more clear. A thank you very much. Maybe can you tell me if developer team is planning retake this matter?
April 6, 2021 at 11:22 AM #26987[email protected]
ParticipantHello any news about this?
April 14, 2021 at 2:41 PM #27232Long Nguyen
ModeratorHi Luis,
Sorry for the late reply.
With the custom code above, I think you can re-order the custom fields of the user profile/register form, as well as the frontend submit form.
https://metabox.io/frontend-submission-reorder-post-fields/ -
AuthorPosts
- You must be logged in to reply to this topic.