Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to auto generate username from first and last name?

  • Avatar of viniciusb
    Vinnie Barbarino
    Participant

    @viniciusb

    I’m trying to create a registration page with ‘first name’, ‘last name’, ‘email’ and ‘password’, without the need for the user to create a username.

    The username would be autogenerated off of the user’s first and last name. E.g. If user’s name is John Doe, his username would be automatic created as ‘john_doe’.

    If another user registered with that same name, username “john_doe_1″ would be created – as WP does with images.

    I know this is possible because that is how “Login/Register with FB plugins” do.

    A plugin that did that would be ideal, but I couldn’t find anything.

Viewing 1 replies (of 1 total)
  • Avatar of henrywright
    henrywright
    Participant

    @henrywright

    Just do something like this: $username = $first . '_' . $last;

    If you need to check a username exists, you can do: if ( username_exists( $username ) )

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.