Example #1
0
 // optional fields
 if ($name != '') {
     $user->setName($name);
 }
 if ($sex != '') {
     $user->setSex($sex);
 }
 if ($location != '') {
     $user->setLocation($location);
 }
 if ($biography != '') {
     $user->setBiography($biography);
 }
 $user->save();
 // save the user
 $user->setLastLogin($user->getDateCreated());
 $user->save();
 // save last login as date created
 // log the event
 $logEvent = new Event(array('event_type_id' => 'create_user', 'user_1_id' => $user->getId()));
 $logEvent->save();
 // email confirmation
 $body = '<p>You have successfully registered for <a href="' . Url::base() . '">' . PIPELINE_NAME . '</a>.</p>';
 $body .= '<p>Your username is ' . formatUserLink($user->getID()) . '. Have fun!</p>';
 $newEmail = array('to' => $email, 'subject' => '[' . PIPELINE_NAME . '] Welcome to ' . PIPELINE_NAME . '!', 'message' => $body);
 Email::send($newEmail);
 // log us into the new account
 Session::signIn($user->getId());
 // link any email invites to this user
 Invitation::linkByEmail($email, $user->getID());
 // set confirm message and send us away