• Resolved matteodioto

    (@matteodioto)


    Hi, I’m trying to change the username that is automatically generated when a user registers on my site, I would like the username to always be first_name.last_name, I’ve tried different hooks but unfortunately the result never changes, every time it is generated in automatic way a username that decides the system, how can I solve it? This is the last snippet I used:

    add_action(‘um_registration_before_auto_user_id’, ‘custom_username_from_name_and_lastname_UM’, 10, 1);

    function custom_username_from_name_and_lastname_UM($args) {
    $first_name = isset($args[‘first_name’]) ? $args[‘first_name’] : ”;
    $last_name = isset($args[‘last_name’]) ? $args[‘last_name’] : ”;

    if ($first_name && $last_name) {
        $username = sanitize_user($first_name . '.' . $last_name);
        $args['user_login'] = $username;
    }
    
    return $args;

    }

    The page I need help with: [log in to see the link]

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

The topic ‘edit default automatically username after wordpress registration’ is closed to new replies.