$this->SessionHandler('destroy');
$this->FormatMessage($this->LanguageArray[100].$modx->config['site_name']);
include('customized_code.php'); //more code
return 'success'; // Generate username from firstname and lastname:
if(isset($_POST['firstname']) && $_POST['firstname'] != '')
{
$firstname = $modx->db->escape($modx->stripTags($_POST['firstname']));
}
if(isset($_POST['lastname']) && $_POST['lastname'] != '')
{
$lastname = $modx->db->escape($modx->stripTags($_POST['lastname']));
}
//Contruct username with: first letter of firstname and the lastname without any whitespaces
// 1. char for firstname last name with no whitespace
$username = substr(trim($firstname),0,1).ereg_replace( ' +', '',trim($lastname));
//username to lowercase
$username = strtolower($username);
//Check if username exists
$checkUsername = $modx->db->query("SELECT `id` FROM ".$web_users." WHERE `username`='".$username."'");
$limit = $modx->recordCount($checkUsername);
//if so, add a number at this end
$attachednumer = 1;
while($limit > 0)
{
$newusername = $username.$attachednumer;
$attachednumer++;
$checkUsername = $modx->db->query("SELECT `id` FROM ".$web_users." WHERE `username`='".$newusername."'");
$limit = $modx->recordCount($checkUsername);
$username = $newusername;
}
//put the username to the right object variable
$this->Username = $username;