本文整理汇总了PHP中UserAuth::addUserBasic方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAuth::addUserBasic方法的具体用法?PHP UserAuth::addUserBasic怎么用?PHP UserAuth::addUserBasic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAuth
的用法示例。
在下文中一共展示了UserAuth::addUserBasic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUser
/**
* Create a new user
*/
public function createUser($h)
{
$error = 0;
// check username
$username = $h->cage->post->testUsername('username');
// alphanumeric, dashes and underscores okay, case insensitive
if (!$username) {
$h->messages[$h->lang['user_signin_register_username_error']] = 'red';
$error = 1;
} else {
$h->vars['user_man_username_1'] = $username;
}
// check email
$email = $h->cage->post->testEmail('email');
if (!$email) {
$h->messages[$h->lang['user_signin_register_email_error']] = 'red';
$error = 1;
} else {
$h->vars['user_man_email'] = $email;
}
// process new user
if (!$error) {
$us = new UserSignin();
$blocked = $us->checkBlocked($h, $username, $email);
// true if blocked, false if safe
$exists = $h->userExists(0, $username, $email);
if (!$blocked && $exists == 'no') {
// SUCCESS!!!
$userAuth = new UserAuth();
$userAuth->name = $username;
$userAuth->email = $email;
$userAuth->emailValid = 1;
$userAuth->password = random_string(10);
// temporary until user is created
$userAuth->addUserBasic($h);
$last_insert_id = $h->db->get_var($h->db->prepare("SELECT LAST_INSERT_ID()"));
// send password!
$passconf = md5(crypt(md5($userAuth->email), md5($userAuth->email)));
$userAuth->newRandomPassword($h, $last_insert_id, $passconf);
$h->messages[$h->lang['user_man_add_success_password_sent']] = 'green';
$user = '';
$email = '';
// clear the form.
} elseif ($exists == 'id') {
$h->messages[$h->lang['user_signin_register_id_exists']] = 'red';
} elseif ($exists == 'name') {
$h->messages[$h->lang['user_signin_register_username_exists']] = 'red';
} elseif ($exists == 'email') {
$h->messages[$h->lang['user_signin_register_email_exists']] = 'red';
} elseif ($blocked) {
$h->messages[$h->lang['user_signin_register_user_blocked']] = 'red';
}
}
}