user registration
-
Hello, I make test, if I register my last name and first name without capitalization, I receive the email confirmation without capitalization.
I would to know if there is way to force capitalization inside the mail for {display_name}, like this if user enter his first name and last name without capitalization, he can receive the confirmation mail with his first and last name with capitalization.
I try to add inside the email backoffice
<span style=”text-transform: capitalize”>{display_name}</span>
but doesnt worksThanks for your help
Regards
Michel
-
Try to use this code snippet for UTF-8 safe display name capitalization.
Install into your active theme’s functions.php file
or use the “Code Snippets” plugin.add_filter( 'um_user_display_name_filter', 'um_user_display_name_filter_custom', 10, 3 ); function um_user_display_name_filter_custom( $name, $user_id, $html ) { $chars = mb_str_split( $name ); $cap_name = ''; $cap = true; foreach( $chars as $char ) { if( $cap ) { $cap_name .= mb_strtoupper( $char ); $cap = false; } else { $cap_name .= $char; if( $char == ' ' || $char == '-' ) $cap = true; } } return $cap_name; }Thanks, but this code give me error blank page
It’s probably an issue with the Multibyte String library is missing in PHP.
If you have access to cPanel you can add this library as
mbstringto your current PHP installation.Ok will ask to the hosting and tell you
I have added a test to exit without capitalizing the display name if the PHP Multibyte Extension is not loaded.
add_filter( 'um_user_display_name_filter', 'um_user_display_name_filter_custom', 10, 3 ); function um_user_display_name_filter_custom( $name, $user_id, $html ) { if( !extension_loaded('mbstring')) return $name; $chars = mb_str_split( $name ); $cap_name = ''; $cap = true; foreach( $chars as $char ) { if( $cap ) { $cap_name .= mb_strtoupper( $char ); $cap = false; } else { $cap_name .= $char; if( $char == ' ' || $char == '-' ) $cap = true; } } return $cap_name; }I get the same error
How do you install the code snippet?
More changes:
New function name if you already have a conflict with a function with previous name.
Changing the display name all characters to lowercase before capitalizing.
Keep lowercase for these attributes: von, de, duc, d’, da, del, yadd_filter( 'um_user_display_name_filter', 'um_user_display_name_filter_capitalization', 10, 3 ); function um_user_display_name_filter_capitalization( $name, $user_id, $html ) { if( !extension_loaded( 'mbstring' )) return $name; $chars = mb_str_split( mb_strtolower( $name )); $cap = true; $cap_flags = array( ' ', '-', "'" ); $cap_name = ''; foreach( $chars as $char ) { if( $cap ) { $cap_name .= mb_strtoupper( $char ); $cap = false; } else { $cap_name .= $char; if( in_array( $char, $cap_flags )) $cap = true; } } $cap_language = array(); $cap_language['lower'] = array( ' von ', ' de ', ' duc ', " d'", ' da ', ' del ', ' y ' ); $cap_language['upper'] = array( ' Von ', ' De ', ' Duc ', " D'", ' Da ', ' Del ', ' Y ' ); $cap_name = str_replace( $cap_language['upper'], $cap_language['lower'], $cap_name ); return $cap_name; }Hello, thanks working well thanks π
I make a test with my name, its OKBut its working for all fisrt and last name ? And for all language ? ( my website is in FR/EN/ES/DE/IT/PT )
because of this line : Keep lowercase for these attributes: von, de, duc, dβ, da, del, y
Thanks very much
Michel
-
This reply was modified 3 years, 6 months ago by
benenoo.
But its working for all fisrt and last name ? And for all language ? ( my website is in FR/EN/ES/DE/IT/PT )
because of this line : Keep lowercase for these attributes: von, de, duc, dβ, da, del, y
I used this guide for defining these attributes:
https://libguides.dickinson.edu/citing/mla7capitalization
Maybe I should make these attributes easy to add new or delete in UM Settings?
-
This reply was modified 3 years, 6 months ago by
missveronica.
More changes:
Now Mc will be followed by a capital character like in McDonaldadd_filter( 'um_user_display_name_filter', 'um_user_display_name_filter_capitalization', 10, 3 ); function um_user_display_name_filter_capitalization( $name, $user_id, $html ) { if( !extension_loaded( 'mbstring' )) return $name; $chars = mb_str_split( mb_strtolower( $name )); $cap = true; $cap_flags = array( ' ', '-', "'" ); $cap_name = ''; foreach( $chars as $char ) { if( $cap ) { $cap_name .= mb_strtoupper( $char ); $cap = false; } else { $cap_name .= $char; if( in_array( $char, $cap_flags )) $cap = true; } } $cap_language = array(); $cap_language['lower'] = array( ' von ', ' de ', ' duc ', " d'", ' da ', ' del ', ' y ' ); $cap_language['upper'] = array( ' Von ', ' De ', ' Duc ', " D'", ' Da ', ' Del ', ' Y ' ); $cap_name = str_replace( $cap_language['upper'], $cap_language['lower'], $cap_name ); if( mb_strpos( $cap_name, 'Mc' ) !== false ) { $strings = explode( 'Mc', $cap_name ); $cap_name = $strings[0] . 'Mc' . mb_strtoupper( mb_substr( $strings[1], 0, 1 )) . mb_substr( $strings[1], 1 ); } return $cap_name; }Thanks works well π
Now you can download and replace this code snippet with the UM improved version:
“Force Capitalization of Display Name( First and Last Names )”
from the UM free Extended plugins at:
-
This reply was modified 3 years, 6 months ago by
The topic ‘user registration’ is closed to new replies.