great module but

bonhommie - August 19, 2008 - 16:46
Project:Auto username
Version:5.x-1.x-dev
Component:User interface
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

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

#1

dwadson - November 19, 2008 - 18:18

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;
?>

#2

dwadson - November 19, 2008 - 18:28

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.

<?php
$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;
?>

 
 

Drupal is a registered trademark of Dries Buytaert.