Custom Fields
Re-Envisioned
Support MB User Profile mb_user_profile_register autocomplete="new-password" ?

  • Creator
    Topic
  • #27125
    Resolved Adam 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" ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #27139
    Long 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://metabox.io/support/topic/registration-username-as-email-duplicated-fields-avatar-visibility-issue/
    https://metabox.io/support/topic/sort-the-username-and-email-fields/

    #27210
    Adam 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 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.