Support Forum
Support › MB User Profile › Translate "This field is required." on "mb_user_profile_login" shortcodeResolved
Hello,
I would like to translate the message "This field is required" when using "mb_user_profile_login" shortcode. Is this possible? And I guess the same goes with register or update form.
If not, is there any workaround to create custom login/register/update form?
Thank you,
Matej
Hi,
Please refer to this topic to know how to translate the validation text https://support.metabox.io/topic/translation-of-form-messages/
Thank you, I saw this thread but I can't figure it out. If I use [mb_user_profile_login], how can I add "validation" part to the field group settings?
I can see that there is a "rwmb_profile_login_fields" filter, but this is only for changing fields, not adding to the field group settings?
I use this shortcode: https://docs.metabox.io/extensions/mb-user-profile/#login-form
If you have any example it would be great rf if you can point me in the right direction.
Thanks.
Hi,
You can use filter hook rwmb_profile_login_fields
to add the custom HTML5 attribute title
to the field and change the required message. For example:
add_filter( 'rwmb_profile_login_fields', function( $fields ) {
$fields['username']['attributes'] = [
'title' => 'Username required text'
];
$fields['password']['attributes'] = [
'title' => 'Password required text'
];
return $fields;
} );
Read more on the documentation https://docs.metabox.io/custom-attributes/
https://www.w3schools.com/tags/att_global_title.asp
Hi,
thanks for help. Although it's now a long time since I originally asked a question, I needed this again and I decided to write here my solution for anyone that would be in same dilemma. The answer was is almost correct and it pointed me in the right direction.
I forgot to answer it last year, because I solved this some other way and I totally forgot about this question.
Because I was using [mb_user_profile_info id="rwmb-user-info"]
shortcode, I needed to create a filter like this:
add_filter( 'rwmb_profile_info_fields', function( $fields ) {
error_log(print_r($fields, true));
$fields['password']['attributes'] = [
'title' => 'Username required text'
];
$fields['password2']['attributes'] = [
'title' => 'Password required text'
];
return $fields;
});