• Resolved colinsp

    (@colinsp)


    Is there a way to pre-populate the username / create the user name using the registrant’s first name and surname? Either by hiding the field or making it non-editable?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @colinsp

    You can try this code snippet:

    add_filter("um_add_user_frontend_submitted", function( $args ){
    
        $args['user_login'] = $args['first_name'].".".$args['last_name'];
    
        if ( username_exists( $args['user_login'] ) ) {
            UM()->form()->add_error( 'first_name', __( 'Username is already linked to another account', 'ultimate-member' ) );
        }
    
        return $args;
    });

    You can add the code snippet in your theme’s functions.php file or use the Code Snippets plugin: https://wordpress.org/plugins/code-snippets/

    Regards,

    Thread Starter colinsp

    (@colinsp)

    Sorry for the delay in replying.

    This worked absolutely perfectly, thank you very much

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.