mb_user_profile_register autocomplete="new-password" ?

Support MB User Profile mb_user_profile_register autocomplete="new-password" ?Resolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27125
    Adam MAdam M
    Participant

    With the user registration shortcode [mb_user_profile_register ...], is there any way to force the resulting HTML to use label autocomplete="new-password", so that users get the browser facility of "Suggest a strong password" ?

    #27139
    Long NguyenLong Nguyen
    Moderator

    Hi Adam,

    Thank you for getting in touch.

    If you want to add any attribute to a field input, please follow this documentation https://docs.metabox.io/custom-attributes/.

    Then use filter rwmb_profile_register_fields to customize/modify the user register fields.

    Sample code:

    function add_more_registration_fields( $fields ) {
            $fields = [
                'password'  => [
                    'name'     => __( 'Password', 'mb-user-profile' ),
                    'id'       => 'user_pass',
                    'type'     => 'password',
                    'required' => true,
                    'desc'     => '<span id="password-strength" class="rwmb-password-strength"></span>',
                    'attributes' => [
                        'autocomplete' => 'new-password'
                    ]
                ],
                '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,
                ],           
                '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' );

    Refer to the topic
    https://support.metabox.io/topic/registration-username-as-email-duplicated-fields-avatar-visibility-issue/
    https://support.metabox.io/topic/sort-the-username-and-email-fields/

    #27210
    Adam MAdam M
    Participant

    Thank you. That was helpful.

    To restate for those who are at least as slow as me: the registration fields created by shortcode [mb_user_profile_register ...] are internally generated. However, using filter rwmb_profile_register_fields means that all these internally-created fields are passed to the filter for rewriting from scratch.

    The snippet above does this, with the difference between it and the internally-generated representation being that the password-related attribute I wanted is there:

    'attributes' => [
        'autocomplete' => 'new-password'
    ]
    
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.