I have not been able to figure out how you extract the last initial from the lastname field? Or do you simply request a last initial from user?
I want to use firstname last-initial as username.
thanks

Comments

dwadson’s picture

To get first-initial lastname as the username, I used this PHP code:

<?php
$firstname=[profile_firstname-filtered];
$temp_username=$firstname[0].[profile_lastname-raw];
$temp_username=strtolower($temp_username);
return $temp_username;
?>
dwadson’s picture

Here's a modification that will take a hypenated lastname ("Jones-Smith") and just use the last "word" in the username. Change the Punctuation Settings to leave hypens unchanged.

$firstname="[profile_firstname-filtered]";
$lastname="[profile_lastname-filtered]";

$token = strtok($lastname, "-");
while ($token !== false) {
  $lastnameTemp=$token;
  $token = strtok("-");
}
$temp_username=$firstname[0].$lastnameTemp;
$temp_username=strtolower($temp_username);

return $temp_username;
alexkb’s picture

Status: Active » Closed (won't fix)

Thanks for the report and sorry this wasn't fixed at the time it was relevant. I'm new to this project, but cleaning up the issue queue, so closing this issue given its on a very old branch. Thanks.