• Resolved Richard

    (@tywest)


    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]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jarryd Long

    (@jarryd-long)

    Hi there, thank you for reaching out to the Paid Memberships Pro team.

    I’ve had a look at the code recipe and it looks like you’re on the right track. Please let me know how we can assist with this and if there are any other changes required.

    Kind Regards,
    Jarryd
    Support Manager at Paid Memberships Pro

    Plugin Support Jarryd Long

    (@jarryd-long)

    Because there have not been any recent updates to this topic, we will be changing the status to resolved. If you have any other questions regarding this issue please start a new topic for each question to ensure we can provide the best support possible.

    Kind Regards,
    Jarryd
    Support Manager at Paid Memberships Pro

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom Username’ is closed to new replies.