Custom Fields
Re-Envisioned
Support MB User Profile Unable to reposition the 'user_pass' field inside the user register form

  • Creator
    Topic
  • #33073
    Resolved Nicholas Cox
    Participant

    Hi

    I am using the register shortcode with my metabox setup and I am including the default fields inside my form. All is working fine except for the 'user_pass' field id. Currently my form has all of the fields in order but the password and password confirmation are located at the very top of the form. How do I go about changing the position of this?

    
    'fields'  => [
        [
            'type'  => 'text',
            'name'  => 'First Name',
            'id'    => 'first_name', 
            'desc'  => '',
            'class' => 'dc-first-name',
        ],
        [
            'type'  => 'text',
            'name'  => 'Last Name', 
            'id'    => 'last_name', 
            'desc'  => '',
            'class' => 'dc-last-name',
        ],
        [
            'type'    => 'email',
            'name'    => 'Email', 
            'id'      => 'user_email',
            'class' => 'dc-user-email',
        ],
        [
            'type'    => 'password',
            'name'    => 'Password', 
            'id'      => 'user_pass', 
            'class' => 'dc-user-pass',
        ]
    ]
    
    
    [mb_user_profile_register id="user" label_submit="Register" confirmation="Your account has been created, please click the verify link sent to your registered email address."]
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #33074
    Nicholas Cox
    Participant

    after looking at the documentation, the 'user_email' field also does not work in that it does not reposition the form field? it adds an email field e.g. below to the form, but the existing email field is still visible and located at the top of the form.

    https://docs.metabox.io/extensions/mb-user-profile/#edit-default-fields

    
    'fields'  => [
        [
            'type'    => 'email',
            'name'    => 'Email', 
            'id'      => 'user_email', 
            'class' => 'dc-user-email',
        ]
    ]
    
    #33087
    Long Nguyen
    Moderator

    Hi,

    The default fields here https://docs.metabox.io/extensions/mb-user-profile/#edit-default-fields
    is used for the user profile shortcode, not for the user register shortcode.

    If you want to modify the fields of the user register shortcode, please use the filter rwmb_profile_register_fields. For example:

    add_filter( 'rwmb_profile_register_fields', function( $fields ) {
        $fields = [
            '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,
            ],
            'username'  => [
                'name'     => __( 'Username', 'mb-user-profile' ),
                'id'       => 'user_login',
                'type'     => 'text',
                'required' => true,
            ],
        ];
        return $fields;
    } );

    Refer to the documentation https://docs.metabox.io/extensions/mb-user-profile/#form-fields-filters

    #33094
    Nicholas Cox
    Participant

    Hi

    Thanks for the explanation, I think as all of the documentation is on one page for the register and edit profile it can get quite confusing to understand when implementing both forms at the same time.

    I have now managed to sort the issue. Thanks!

    #33098
    Nicholas Cox
    Participant

    One thing which is not clear in the docs is that I originally wanted to use one form for both the 'register' and the 'edit profile' shortcodes. What I have just figured out is that the (email, password, password2 and username) are automatically hidden on the 'edit profile' shortcode. This means I cannot split these fields up so they appear next to other form fields created in metabox.

    e.g.

    Field1
    Username
    Field 2
    Password
    Password2
    Field 3
    Email

    I basically have to only re-order the 4 fields and they will always appear at the top of the front end form?

    e.g.
    Username
    Password
    Password2
    Email
    ---- rest of the fields appear after...

    #33109
    Long Nguyen
    Moderator

    Hi,

    On the documentation, we do not mention that the user registration form can be edited with a meta box and default fields, it is located under the user profile form. That means it is not possible to use one meta box for two forms like that.

    If you want to add more custom fields to the registration form or re-order fields, please use the filter above.

    add_filter( 'rwmb_profile_register_fields', function( $fields ) {
        $fields = [
            '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,
            ],
            'username'  => [
                'name'     => __( 'Username', 'mb-user-profile' ),
                'id'       => 'user_login',
                'type'     => 'text',
                'required' => true,
            ],
            'display_name' => [
                'name'     => __( 'Display Name', 'mb-user-profile' ),
                'id'       => 'display_name',
                'type'     => 'text',
            ]
        ];
        return $fields;
    } );
    #33132
    Nicholas Cox
    Participant

    Hi

    Ah ok I was going to mention I was using one metabox id with two forms. I did not want to repeat my code by repeating the field values for each form. But I will change this now.

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