mb_user_profile_register autocomplete="new-password" ?
Support › MB User Profile › mb_user_profile_register autocomplete="new-password" ?Resolved
- This topic has 2 replies, 2 voices, and was last updated 4 years ago by
Adam M.
-
AuthorPosts
-
April 10, 2021 at 11:48 PM #27125
Adam M
ParticipantWith the user registration shortcode
[mb_user_profile_register ...]
, is there any way to force the resulting HTML to use labelautocomplete="new-password"
, so that users get the browser facility of "Suggest a strong password" ?April 11, 2021 at 1:36 PM #27139Long Nguyen
ModeratorHi 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/April 13, 2021 at 8:29 PM #27210Adam M
ParticipantThank 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 filterrwmb_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' ]
-
AuthorPosts
- You must be logged in to reply to this topic.