To answer my own question -
create a plugin - VBMS Add-Alias.
Hook - register_activate_start
Code -
PHP Code:
$count = 1;
function str_split_php4($text, $split = 1)
{
if (!is_string($text)) return false;
if (!is_numeric($split) && $split < 1) return false;
$len = strlen($text);
$array = array();
$i = 0;
while ($i < $len)
{
$key = NULL;
for ($j = 0; $j < $split; $j += 1)
{
$key .= $text{$i};
$i += 1;
}
$array[] = $key;
}
return $array;
}
function make_alias($username)
{
$alias = strtolower($username);
$alias = str_replace(" ", "_", $alias);
$holdarr = str_split_php4($alias);
foreach ($holdarr as $val) {
if ((ord($val) >= 48 AND ord($val) <= 57) OR (ord($val) >= 45 AND ord($val) <= 46) OR (ord($val) == 95) OR (ord($val) >=97 AND ord($val) <=122)) $final .= $val;
}
return $final;
}
$newalias = make_alias($vbulletin->userinfo['username']);
$fixedalias = $newalias;
$aliascheck = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE vbms_alias ='" . $newalias . "'");
while ($aliascheck[vbms_alias]) {
$fixedalias = $newalias . $count;
$aliascheck = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE vbms_alias ='" . $fixedalias . "'");
$count++;
}
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user
SET vbms_alias = '" . $fixedalias . "'
WHERE userid = '" . $vbulletin->userinfo['userid'] . "'
");
This will take the alias, make it lowercase, strip anything other than A-Z and 1-9, replace spaces with underscores, then check the DB to make sure no one has the same alias.
If someone else has the same alias it will add a 1 at the end... check again... etc.
It will only add the alias to people who complete registration - so people can't register a user, autmatically get a alias, and spam the mailbox to waste space/load the server...
If anyone sees any problems... let me know.
Might be nice to add this to the release as an option that can be turned on/off.