PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Username of First name and first letter Last name

  1. Is it possible to assign a username to a new user using the First Name + 1st letter of the Surname? Like Robert R., I think I'm in the right direction using
    but can't get it work. Any suggestions on this are welcome!

           add_filter('gform_username', 'auto_username');
    function auto_username($username){
        $username = strtolower(rgpost('input_1_3') . $string[0];(rgpost('input_1_4')));
            return $username;
            require_once(ABSPATH . WPINC . "/registration.php");
            $i = 2;
            while(username_exists($username . $i)){
            $username = $username . $i;
        return $username;
    Posted 7 years ago on Saturday January 5, 2013 | Permalink
  2. Line 05 should look more like this:

    $username = strtolower(rgpost('input_1_3') . ' ' . substr(rgpost('input_1_6'), 0, 1));

    That assumes field 1 is your name field. If not, the 1_3 and 1_6 will need to change.

    Also, you said "Robert R" but this will create "robert r" since you are using strtolower.

    Posted 7 years ago on Saturday January 5, 2013 | Permalink