Custom Username | WordPress.org
Hi. I’d like my member’s usernames to be constrained to A-Z, 0-9, with no spaces, default to uppercase, and with a maximum of 8 characters in length. If there is a way to also set the default font-family as well, that would be great. I have Code Snippets installed and have made several attempts, but nothing I’ve tried affects the Username field on the account setup page.
Here is an example of what I have tried:
function my_custom_user_registration_changes( $userdata ) {
// Remove any spaces $user_login = str_replace(‘ ‘, ”, $userdata[‘user_login’]);
// Remove any characters that are not letters or numbers $user_login = preg_replace(‘/[^A-Za-z0-9]/’, ”, $user_login);
// Convert to uppercase $user_login = strtoupper($user_login);
// Trim to a maximum length of 8 characters $user_login = substr($user_login, 0, 8);
// Assign the cleaned and formatted user login back to userdata $userdata[‘user_login’] = $user_login; return $userdata; }
add_filter(‘pmpro_checkout_new_user_array’, ‘my_custom_user_registration_changes’, 10, 1);
The page I need help with: [log in to see the link]
مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد
منبع: انجمن وردپرس