Sort the username and email fields

Support MB User Meta Sort the username and email fieldsResolved

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #24763
    clientes@interficto.com[email protected]
    Participant

    Hello, 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.png

    However I want sort my form in different order, for example:
    First name
    Last name
    Email address
    other_custom_field
    Username
    Password
    Confirm password

    How can I get it? is possible

    Thank you in advanced!

    #24766
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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.

    #24852
    clientes@interficto.com[email protected]
    Participant

    Sorry but I don't understand. I added it code in my functions.php and i didn't get nothing. What should I do?

    #24861
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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/.

    #24890
    clientes@interficto.com[email protected]
    Participant

    Hello, I did it but it doesn't work correctly:

    1. 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?
    2. 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
    3. With this approach can I use "Custom table extension" Can you explainme please?
    4. In this post:

    https://support.metabox.io/topic/registration-username-as-email-duplicated-fields-avatar-visibility-issue/page/2/#post-18239

    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?

    #24906
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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.

    #24908
    clientes@interficto.com[email protected]
    Participant

    295 / 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/3Wo1xwf

    Now 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

    #24916
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Sorry if I misunderstood your questions. I will try to reply sequently.

    1. 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.
    2. Please try again with this code (remove the array key)
    3. 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;
      }
    4. 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.
    5. I will inform the Keymaster to take a look at that case.
    #26518
    clientes@interficto.com[email protected]
    Participant

    Hello now it is more clear. A thank you very much. Maybe can you tell me if developer team is planning retake this matter?

    #26987
    clientes@interficto.com[email protected]
    Participant

    Hello any news about this?

    #27232
    Long NguyenLong Nguyen
    Moderator

    Hi 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/

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.