本文整理汇总了PHP中validate_username函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_username函数的具体用法?PHP validate_username怎么用?PHP validate_username使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_username函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: phpBBRegister
private function phpBBRegister($userObj)
{
$save_sytem_config = $GLOBALS['config'];
global $phpbb_root_path;
global $phpEx;
$messages = array();
$phpbb_root_path = $this->_phpbb_src;
$phpEx = 'php';
ob_start();
if (is_readable($this->_phpbb_src . 'config.php') and is_executable($this->_phpbb_src . 'config.php') and is_readable($this->_phpbb_src . 'common.php') and is_executable($this->_phpbb_src . 'common.php') and is_readable($this->_phpbb_src . 'includes/functions_user.php') and is_executable($this->_phpbb_src . 'includes/functions_user.php')) {
require_once $this->_phpbb_src . 'config.php';
require_once $this->_phpbb_src . 'common.php';
require_once $this->_phpbb_src . 'includes/functions_user.php';
} else {
$messages[] = $this->lang('noaccessphpbbfiles.session.error');
$messages[] = $this->_phpbb_src . 'config.php<br/>' . $this->_phpbb_src . 'common.php<br/>' . $this->_phpbb_src . 'includes/functions_user.php<br/>';
return $messages;
}
if (!validate_username($userObj->u_login)) {
$user_row = array('username' => $userObj->u_login, 'user_password' => phpbb_hash($userObj->u_pass), 'user_email' => $userObj->u_email, 'group_id' => 7, 'user_timezone' => 0.0, 'user_dst' => 0, 'user_lang' => 'ru', 'user_type' => 0, 'user_actkey' => '', 'user_dateformat' => '|d M Y|, H:i', 'user_style' => 1, 'user_regdate' => time());
$lid = user_add($user_row);
if (!$lid) {
$messages[] = $this->lang('cannotadduser.session.error');
}
} else {
$messages[] = $this->lang('loginallreadyexists.session.error');
}
ob_end_clean();
$GLOBALS['config'] = $save_sytem_config;
if (count($messages)) {
return $messages;
} else {
return false;
}
}
开发者ID:ValenokPC,项目名称:tabernacms,代码行数:35,代码来源:registerphpbb.php
示例2: userCheck
function userCheck($username, $user_email)
{
global $user_prefix, $db, $DeniedUserNames, $CensorList;
try {
validate_username($username);
} catch (Exception $e) {
cpg_error($e);
}
$email = Security::check_email($user_email);
if ($email == 0) {
cpg_error('Email address to short');
}
if ($email == -1) {
cpg_error(sprintf(_ERROR_BAD_FORMAT, 'email'));
}
if ($email == -2) {
cpg_error('The email address domain "' . $user_email[1] . '" is disallowed for registration.');
}
if ($db->sql_count($user_prefix . '_users', "user_email='{$user_email}'") > 0 || $db->sql_count($user_prefix . '_users_temp', "user_email='{$user_email}'") > 0) {
cpg_error(_EMAILREGISTERED);
}
/* Now check deleted PHP-Nuke account emails */
if ($db->sql_count($user_prefix . '_users', "user_email='" . md5($user_email) . "'") > 0) {
cpg_error(_EMAILNOTUSABLE);
}
return;
}
开发者ID:cbsistem,项目名称:nexos,代码行数:27,代码来源:functions.php
示例3: login_submit
/**
* Processes credentials to pass into wp_signon to log a user into WordPress.
*
* @uses check_ajax_referer()
* @uses wp_signon()
* @uses is_wp_error()
*
* @param $user_login (string) Defaults to $_POST['user_login']
* @param $password (string)
* @param $is_ajax (bool) Process as an AJAX request
* @package AJAX
*
* @return userlogin on success; 0 on false;
*/
public function login_submit($user_login = null, $password = null, $is_ajax = true)
{
/**
* Verify the AJAX request
*/
if ($is_ajax) {
check_ajax_referer('login_submit', 'security');
}
$username = empty($_POST['user_login']) ? $user_login : sanitize_text_field($_POST['user_login']);
$password = empty($_POST['password']) ? $password : sanitize_text_field($_POST['password']);
$remember = !empty($_POST['rememberme']) ? true : false;
// Currently wp_signon returns the same error code 'invalid_username' if
// a username does not exists or is invalid
if (validate_username($username)) {
if (username_exists($username)) {
$creds = array('user_login' => $username, 'user_password' => $password, 'remember' => $remember);
$user = wp_signon($creds, false);
$status = is_wp_error($user) ? $this->status($user->get_error_code()) : $this->status('success_login');
} else {
$status = $this->status('username_does_not_exists');
}
} else {
$status = $this->status('invalid_username');
}
if ($is_ajax) {
wp_send_json($status);
} else {
return $status;
}
}
开发者ID:venturepact,项目名称:blog,代码行数:44,代码来源:login.php
示例4: registration_validation
function registration_validation($username, $password, $email)
{
global $reg_errors;
$reg_errors = new WP_Error();
if (empty($username) || empty($password) || empty($email)) {
$reg_errors->add('field', 'Required form field is missing');
}
if (4 > strlen($username)) {
$reg_errors->add('username_length', 'Username too short. At least 4 characters is required');
}
if (username_exists($username)) {
$reg_errors->add('user_name', 'Sorry, that username already exists!');
}
if (!validate_username($username)) {
$reg_errors->add('username_invalid', 'Sorry, the username you entered is not valid');
}
if (5 > strlen($password)) {
$reg_errors->add('password', 'Password length must be greater than 5');
}
if (!is_email($email)) {
$reg_errors->add('email_invalid', 'Email is not valid');
}
if (email_exists($email)) {
$reg_errors->add('email', 'Email Already in use');
}
if (is_wp_error($reg_errors)) {
foreach ($reg_errors->get_error_messages() as $error) {
echo '<div>';
echo '<strong>ERROR</strong>:';
echo $error . '<br/>';
echo '</div>';
}
}
}
开发者ID:Vasiliy28,项目名称:MyJewelry,代码行数:34,代码来源:form-reg.php
示例5: wppb_check_username_value
function wppb_check_username_value($message, $field, $request_data, $form_location)
{
global $wpdb;
if ($field['required'] == 'Yes') {
if (isset($request_data['username']) && trim($request_data['username']) == '' || $form_location == 'register' && !isset($request_data['username'])) {
return wppb_required_field_error($field["field-title"]);
}
}
if (!empty($request_data['username'])) {
if ($form_location == 'register') {
$search_by_user_login = get_users('search=' . $request_data['username']);
}
if (!empty($search_by_user_login)) {
return __('This username already exists.', 'profile-builder') . '<br/>' . __('Please try a different one!', 'profile-builder');
}
if (!validate_username($request_data['username'])) {
return __('This username is invalid because it uses illegal characters.', 'profile-builder') . '<br/>' . __('Please enter a valid username.', 'profile-builder');
}
$wppb_generalSettings = get_option('wppb_general_settings');
if ($wppb_generalSettings['emailConfirmation'] == 'yes') {
if (is_multisite() && $request_data['username'] != preg_replace('/\\s+/', '', $request_data['username'])) {
return __('This username is invalid because it uses illegal characters.', 'profile-builder') . '<br/>' . __('Please enter a valid username.', 'profile-builder');
}
$userSignup = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_login = %s", $request_data['username']));
if (!empty($userSignup)) {
return __('This username is already reserved to be used soon.', 'profile-builder') . '<br/>' . __('Please try a different one!', 'profile-builder');
}
}
}
return $message;
}
开发者ID:ksan5835,项目名称:rankproperties,代码行数:31,代码来源:username.php
示例6: isValidUsername
public static function isValidUsername(\PropertyInterface $prop, $value = null, array $params = array())
{
try {
return validate_username($value);
} catch (\Exception $ex) {
throw new \hypeJunction\Exceptions\ActionValidationException($ex->getMessage());
}
}
开发者ID:hypejunction,项目名称:hypeapps,代码行数:8,代码来源:Validators.php
示例7: process_registration
/**
* Process registration form submission
*
* @since 1.0
*/
public function process_registration($data)
{
if (!isset($_POST['affwp_register_nonce']) || !wp_verify_nonce($_POST['affwp_register_nonce'], 'affwp-register-nonce')) {
return;
}
do_action('affwp_pre_process_register_form');
if (!is_user_logged_in()) {
// Loop through required fields and show error message
foreach ($this->required_fields() as $field_name => $value) {
if (empty($_POST[$field_name])) {
$this->add_error($value['error_id'], $value['error_message']);
}
}
if (username_exists($data['affwp_user_login'])) {
$this->add_error('username_unavailable', __('Username already taken', 'affiliate-wp'));
}
if (!validate_username($data['affwp_user_login'])) {
if (is_multisite()) {
$this->add_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'affiliate-wp'));
} else {
$this->add_error('username_invalid', __('Invalid username', 'affiliate-wp'));
}
}
if (email_exists($data['affwp_user_email'])) {
$this->add_error('email_unavailable', __('Email address already taken', 'affiliate-wp'));
}
if (empty($data['affwp_user_email']) || !is_email($data['affwp_user_email'])) {
$this->add_error('email_invalid', __('Invalid email', 'affiliate-wp'));
}
if (!empty($data['affwp_payment_email']) && $data['affwp_payment_email'] != $data['affwp_user_email'] && !is_email($data['affwp_payment_email'])) {
$this->add_error('payment_email_invalid', __('Invalid payment email', 'affiliate-wp'));
}
if (!empty($_POST['affwp_user_pass']) && empty($_POST['affwp_user_pass2']) || $_POST['affwp_user_pass'] !== $_POST['affwp_user_pass2']) {
$this->add_error('password_mismatch', __('Passwords do not match', 'affiliate-wp'));
}
}
$terms_of_use = affiliate_wp()->settings->get('terms_of_use');
if (!empty($terms_of_use) && empty($_POST['affwp_tos'])) {
$this->add_error('empty_tos', __('Please agree to our terms of use', 'affiliate-wp'));
}
if (!empty($_POST['affwp_honeypot'])) {
$this->add_error('spam', __('Nice try honey bear, don\'t touch our honey', 'affiliate-wp'));
}
if (affwp_is_affiliate()) {
$this->add_error('already_registered', __('You are already registered as an affiliate', 'affiliate-wp'));
}
do_action('affwp_process_register_form');
// only log the user in if there are no errors
if (empty($this->errors)) {
$this->register_user();
$redirect = apply_filters('affwp_register_redirect', $data['affwp_redirect']);
if ($redirect) {
wp_redirect($redirect);
exit;
}
}
}
开发者ID:jwondrusch,项目名称:AffiliateWP,代码行数:62,代码来源:class-register.php
示例8: registration
public function registration($userdata)
{
$reg_errors = new WP_Error();
if (!isset($userdata) && empty($userdata) && !is_array($userdata)) {
$reg_errors->add('data_invalid', 'Chybí vstupní data');
return $reg_errors;
}
$userLogin = array_key_exists('user_login', $userdata) ? sanitize_user($userdata['user_login']) : '';
$userPass = array_key_exists('user_pass', $userdata) ? esc_attr($userdata['user_pass']) : '';
$userEmail = array_key_exists('user_email', $userdata) ? sanitize_email($userdata['user_email']) : '';
$userUrl = array_key_exists('user_url', $userdata) ? esc_url($userdata['user_url']) : '';
$firstName = array_key_exists('first_name', $userdata) ? sanitize_text_field($userdata['first_name']) : '';
$lastName = array_key_exists('last_name', $userdata) ? sanitize_text_field($userdata['last_name']) : '';
$nickname = array_key_exists('nickname', $userdata) ? sanitize_text_field($userdata['nickname']) : '';
$description = array_key_exists('description', $userdata) ? sanitize_text_field($userdata['description']) : '';
if (empty($userLogin) || empty($userPass) || empty($userEmail)) {
$reg_errors->add('field', 'Nejsou vyplnněny povinné pole formuláře.');
}
if (4 > strlen($userLogin)) {
$reg_errors->add('username_length', 'Příliš krátké uživatelské jméno. Zadejte minimálně 5 znaků.');
}
if (username_exists($userLogin)) {
$reg_errors->add('user_name', 'Je nám líto ale uživatelské jméno již existuje.');
}
if (!validate_username($userLogin)) {
$reg_errors->add('username_invalid', 'Neplatné uživatelské jméno.');
}
if (5 > strlen($userPass)) {
$reg_errors->add('password', 'Heslo musí obsahovat minimálně 6 znaků.');
}
if (!is_email($userEmail)) {
$reg_errors->add('email_invalid', 'Zadaný e-mail je ve špatném formátu.');
}
if (email_exists($userEmail)) {
$reg_errors->add('email', 'Zadaný e-mail již existuje.');
}
if (!empty($userUrl)) {
if (!filter_var($userUrl, FILTER_VALIDATE_URL)) {
$reg_errors->add('website', 'Url adresa Vašich stránek není validní.');
}
}
if (is_wp_error($reg_errors) && count($reg_errors->errors) > 0) {
return $reg_errors;
}
$_userdata = array('user_login' => $userLogin, 'user_email' => $userEmail, 'user_pass' => $userPass, 'user_url' => $userUrl, 'first_name' => $firstName, 'last_name' => $lastName, 'nickname' => $nickname, 'description' => $description, 'role' => 'customer');
$user_id = wp_insert_user($_userdata);
if (is_wp_error($user_id)) {
$reg_errors->add('insert_user', 'Registraci nelze dokončit. Kontaktujte prosím správce webu.');
return $reg_errors;
}
// Woocomerce data
if (array_key_exists('billing_first_name', $userdata)) {
add_user_meta($user_id, $meta_key, $meta_value, $unique);
}
$description = array_key_exists('description', $userdata) ? sanitize_text_field($userdata['description']) : '';
return $user_id;
}
开发者ID:netevolution,项目名称:ucetni-portal.cz,代码行数:57,代码来源:up_user.php
示例9: reales_user_signup_form
function reales_user_signup_form()
{
$signup_user = isset($_POST['signup_user']) ? sanitize_text_field($_POST['signup_user']) : '';
$signup_firstname = isset($_POST['signup_firstname']) ? sanitize_text_field($_POST['signup_firstname']) : '';
$signup_lastname = isset($_POST['signup_lastname']) ? sanitize_text_field($_POST['signup_lastname']) : '';
$signup_email = isset($_POST['signup_email']) ? sanitize_email($_POST['signup_email']) : '';
$signup_pass_1 = isset($_POST['signup_pass_1']) ? $_POST['signup_pass_1'] : '';
$signup_pass_2 = isset($_POST['signup_pass_2']) ? $_POST['signup_pass_2'] : '';
$register_as_agent = isset($_POST['register_as_agent']) ? sanitize_text_field($_POST['register_as_agent']) : '';
if (empty($signup_user) || empty($signup_firstname) || empty($signup_lastname) || empty($signup_email) || empty($signup_pass_1) || empty($signup_pass_2)) {
echo json_encode(array('signedup' => false, 'message' => __('Required form fields are empty!', 'reales')));
exit;
}
if (4 > strlen($signup_user)) {
echo json_encode(array('signedup' => false, 'message' => __('Username too short. Please enter at least 4 characters!', 'reales')));
exit;
}
if (username_exists($signup_user)) {
echo json_encode(array('signedup' => false, 'message' => __('Username already exists!', 'reales')));
exit;
}
if (!validate_username($signup_user)) {
echo json_encode(array('signedup' => false, 'message' => __('Invalid Username!', 'reales')));
exit;
}
if (!is_email($signup_email)) {
echo json_encode(array('signedup' => false, 'message' => __('Invalid Email!', 'reales')));
exit;
}
if (email_exists($signup_email)) {
echo json_encode(array('signedup' => false, 'message' => __('Email already exists!', 'reales')));
exit;
}
if (6 > strlen($signup_pass_1)) {
echo json_encode(array('signedup' => false, 'message' => __('Password too short. Please enter at least 6 characters!', 'reales')));
exit;
}
if ($signup_pass_1 != $signup_pass_2) {
echo json_encode(array('reset' => false, 'message' => __('The passwords do not match!', 'reales')));
exit;
}
$user_data = array('user_login' => sanitize_user($signup_user), 'user_email' => sanitize_email($signup_email), 'user_pass' => esc_attr($signup_pass_1), 'first_name' => sanitize_text_field($signup_firstname), 'last_name' => sanitize_text_field($signup_lastname));
$new_user = wp_insert_user($user_data);
if (is_wp_error($new_user)) {
echo json_encode(array('signedup' => false, 'message' => __('Something went wrong!', 'reales')));
exit;
} else {
echo json_encode(array('signedup' => true, 'message' => __('Congratulations! You have successfully signed up.', 'reales')));
reales_signup_notifications($new_user, $signup_pass_1);
if ($register_as_agent != '' && $register_as_agent == 'true') {
reales_register_agent($new_user);
}
}
die;
}
开发者ID:benjaminleeschnell,项目名称:Shason,代码行数:55,代码来源:users.php
示例10: createUserFromPatreon
public static function createUserFromPatreon($user_response, $tokens)
{
global $wpdb;
$email = $user_response['data']['attributes']['email'];
$name = strtolower(str_replace(' ', '', $user_response['data']['attributes']['first_name'] . '_' . $user_response['data']['attributes']['last_name']));
if (validate_username($name) && username_exists($name) == false) {
$username = sanitize_user($name, true);
} else {
$username = explode('@', $user_response['data']['attributes']['email']);
$username = strtolower(sanitize_user($username[0]));
}
if (username_exists($username)) {
$suffix = $wpdb->get_var($wpdb->prepare("SELECT 1 + SUBSTR(user_login, %d) FROM {$wpdb->users} WHERE user_login REGEXP %s ORDER BY 1 DESC LIMIT 1", strlen($username) + 2, '^' . $username . '(\\.[0-9]+)?$'));
if (!empty($suffix)) {
$username .= ".{$suffix}";
}
}
$user = get_user_by('email', $email);
if ($user == false) {
/* create wordpress user if no account exists with provided email address */
$random_password = wp_generate_password(12, false);
$user_id = wp_create_user($username, $random_password, $email);
if ($user_id) {
$user = get_user_by('id', $user_id);
wp_set_current_user($user->ID, $user->user_login);
wp_set_auth_cookie($user->ID);
do_action('wp_login', $user->user_login);
/* update user meta data with patreon data */
update_user_meta($user_id, 'patreon_refresh_token', $tokens['refresh_token']);
update_user_meta($user_id, 'patreon_access_token', $tokens['access_token']);
update_user_meta($user_id, 'patreon_user', $user_response['data']['attributes']['vanity']);
update_user_meta($user_id, 'patreon_created', $user_response['data']['attributes']['created']);
update_user_meta($user_id, 'user_firstname', $user_response['data']['attributes']['first_name']);
update_user_meta($user_id, 'user_lastname', $user_response['data']['attributes']['last_name']);
update_user_meta($user_id, 'patreon_token_minted', microtime());
} else {
/* wordpress account creation failed #HANDLE_ERROR */
}
} else {
/* log user into existing wordpress account with matching email address -- disabled */
// wp_set_current_user( $user->ID, $user->user_login );
// wp_set_auth_cookie( $user->ID );
// do_action( 'wp_login', $user->user_login );
/* update user meta data with patreon data */
update_user_meta($user->ID, 'patreon_refresh_token', $tokens['refresh_token']);
update_user_meta($user->ID, 'patreon_access_token', $tokens['access_token']);
update_user_meta($user->ID, 'patreon_user', $user_response['data']['attributes']['vanity']);
update_user_meta($user->ID, 'patreon_created', $user_response['data']['attributes']['created']);
update_user_meta($user->ID, 'user_firstname', $user_response['data']['attributes']['first_name']);
update_user_meta($user->ID, 'user_lastname', $user_response['data']['attributes']['last_name']);
wp_redirect(wp_login_url() . '?patreon-msg=login_with_patreon', '301');
exit;
}
}
开发者ID:bigt11,项目名称:patreon-wordpress,代码行数:54,代码来源:patreon_login.php
示例11: wc_create_new_customer
/**
* Create a new customer
*
* @param string $email
* @param string $username
* @param string $password
* @return WP_Error on failure, Int (user ID) on success
*/
function wc_create_new_customer($email, $username = '', $password = '')
{
// Check the e-mail address
if (empty($email) || !is_email($email)) {
return new WP_Error("registration-error", __("Please provide a valid email address.", "woocommerce"));
}
if (email_exists($email)) {
return new WP_Error("registration-error", __("An account is already registered with your email address. Please login.", "woocommerce"));
}
wp_verify_nonce($_POST['register'], 'woocommerce-register');
// Handle username creation
if (get_option('woocommerce_registration_generate_username') == 'no' || !empty($username)) {
$username = sanitize_user($username);
if (empty($username) || !validate_username($username)) {
return new WP_Error("registration-error", __("Please enter a valid account username.", "woocommerce"));
}
if (username_exists($username)) {
return new WP_Error("registration-error", __("An account is already registered with that username. Please choose another.", "woocommerce"));
}
} else {
$username = sanitize_user(current(explode('@', $email)));
// Ensure username is unique
$append = 1;
$o_username = $username;
while (username_exists($username)) {
$username = $o_username . $append;
$append++;
}
}
// Handle password creation
if (get_option('woocommerce_registration_generate_password') == 'yes' && empty($password)) {
$password = wp_generate_password();
$password_generated = true;
} elseif (empty($password)) {
return new WP_Error("registration-error", __("Please enter an account password.", "woocommerce"));
} else {
$password_generated = false;
}
// WP Validation
$validation_errors = new WP_Error();
do_action('woocommerce_register_post', $username, $email, $validation_errors);
$validation_errors = apply_filters('woocommerce_registration_errors', $validation_errors, $username, $email);
if ($validation_errors->get_error_code()) {
return $validation_errors;
}
$new_customer_data = apply_filters('woocommerce_new_customer_data', array('user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => 'customer'));
$customer_id = wp_insert_user($new_customer_data);
if (is_wp_error($customer_id)) {
return new WP_Error("registration-error", '<strong>' . __('ERROR', 'woocommerce') . '</strong>: ' . __('Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce'));
}
do_action('woocommerce_created_customer', $customer_id, $new_customer_data, $password_generated);
return $customer_id;
}
开发者ID:prosenjit-itobuz,项目名称:nutraperfect,代码行数:61,代码来源:wc-customer-functions.php
示例12: acl_bp_core_validate_user_signup
function acl_bp_core_validate_user_signup($result)
{
$illegal_names = get_site_option('illegal_names');
if (validate_username($result['user_name']) && !in_array($result['user_name'], (array) $illegal_names)) {
$error_index = array_search(__('Only lowercase letters and numbers allowed', 'buddypress'), $result['errors']->errors['user_name']);
if (isset($error_index)) {
unset($result['errors']->errors['user_name'][$error_index]);
sort($result['errors']->errors['user_name']);
}
}
return $result;
}
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:12,代码来源:allow-capital-letters-in-username.php
示例13: wc_create_new_customer
/**
* Create a new customer.
*
* @param string $email Customer email.
* @param string $username Customer username.
* @param string $password Customer password.
* @return int|WP_Error Returns WP_Error on failure, Int (user ID) on success.
*/
function wc_create_new_customer($email, $username = '', $password = '')
{
// Check the email address.
if (empty($email) || !is_email($email)) {
return new WP_Error('registration-error-invalid-email', __('Please provide a valid email address.', 'woocommerce'));
}
if (email_exists($email)) {
return new WP_Error('registration-error-email-exists', __('An account is already registered with your email address. Please login.', 'woocommerce'));
}
// Handle username creation.
if ('no' === get_option('woocommerce_registration_generate_username') || !empty($username)) {
$username = sanitize_user($username);
if (empty($username) || !validate_username($username)) {
return new WP_Error('registration-error-invalid-username', __('Please enter a valid account username.', 'woocommerce'));
}
if (username_exists($username)) {
return new WP_Error('registration-error-username-exists', __('An account is already registered with that username. Please choose another.', 'woocommerce'));
}
} else {
$username = sanitize_user(current(explode('@', $email)), true);
// Ensure username is unique.
$append = 1;
$o_username = $username;
while (username_exists($username)) {
$username = $o_username . $append;
$append++;
}
}
// Handle password creation.
if ('yes' === get_option('woocommerce_registration_generate_password') && empty($password)) {
$password = wp_generate_password();
$password_generated = true;
} elseif (empty($password)) {
return new WP_Error('registration-error-missing-password', __('Please enter an account password.', 'woocommerce'));
} else {
$password_generated = false;
}
// Use WP_Error to handle registration errors.
$errors = new WP_Error();
do_action('woocommerce_register_post', $username, $email, $errors);
$errors = apply_filters('woocommerce_registration_errors', $errors, $username, $email);
if ($errors->get_error_code()) {
return $errors;
}
$new_customer_data = apply_filters('woocommerce_new_customer_data', array('user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => 'customer'));
$customer_id = wp_insert_user($new_customer_data);
if (is_wp_error($customer_id)) {
return new WP_Error('registration-error', '<strong>' . __('Error:', 'woocommerce') . '</strong> ' . __('Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce'));
}
do_action('woocommerce_created_customer', $customer_id, $new_customer_data, $password_generated);
return $customer_id;
}
开发者ID:johnulist,项目名称:woocommerce,代码行数:60,代码来源:wc-user-functions.php
示例14: validate_credentials
function validate_credentials($form)
{
$errors = [];
$userNameValid = validate_username($form);
if (!$userNameValid) {
$errors["validation.userName"] = "User name is required and should be an email address";
}
$passwordValid = validate_password($form);
if (!$passwordValid) {
$errors["validation.password"] = "Password is required and should have at least 4 characters";
}
return $errors;
}
开发者ID:lihaoxiang1989,项目名称:Marlabs-notes,代码行数:13,代码来源:auth_service.php
示例15: forms_register_generate_username
/**
* Generates a unique available and valid username
*
* @param string $username Username prefix
* @return string
*/
function forms_register_generate_username($username = '')
{
$available = false;
$username = iconv('UTF-8', 'ASCII//TRANSLIT', $username);
$blacklist = '/[\\x{0080}-\\x{009f}\\x{00a0}\\x{2000}-\\x{200f}\\x{2028}-\\x{202f}\\x{3000}\\x{e000}-\\x{f8ff}]/u';
$blacklist2 = array(' ', '\'', '/', '\\', '"', '*', '&', '?', '#', '%', '^', '(', ')', '{', '}', '[', ']', '~', '?', '<', '>', ';', '|', '¬', '`', '@', '-', '+', '=');
$username = preg_replace($blacklist, '', $username);
$username = str_replace($blacklist2, '.', $username);
$ia = elgg_set_ignore_access(true);
$ha = access_get_show_hidden_status();
access_show_hidden_entities(true);
$minlength = elgg_get_config('minusername') ?: 4;
if ($username) {
$fill = $minlength - strlen($username);
} else {
$fill = 8;
}
$algo = elgg_get_plugin_setting('autogen_username_algo', 'forms_register', 'first_name_only');
if ($algo == 'full_name' && $fill <= 0) {
$separator = '.';
} else {
$separator = '';
}
if ($fill > 0) {
$suffix = (new ElggCrypto())->getRandomString($fill);
$username = "{$username}{$separator}{$suffix}";
}
$iterator = 0;
while (!$available) {
if ($iterator > 0) {
$username = "{$username}{$separator}{$iterator}";
}
$user = get_user_by_username($username);
$available = !$user;
try {
if ($available) {
validate_username($username);
}
} catch (Exception $e) {
if ($iterator >= 100) {
// too many failed attempts
$username = (new ElggCrypto())->getRandomString(8);
}
}
$iterator++;
}
access_show_hidden_entities($ha);
elgg_set_ignore_access($ia);
return strtolower($username);
}
开发者ID:hypeJunction,项目名称:Elgg-forms_register,代码行数:56,代码来源:start.php
示例16: verify_account
function verify_account($dirty_username, $dirty_password, $dirty_activation_code)
{
$username = escape($dirty_username);
$password = escape($dirty_password);
$code = escape($dirty_activation_code);
$validateUsrMsg = validate_username($username);
if ($validateUsrMsg != "valid-username") {
return;
}
$validatePwdMsg = validate_password($password);
if ($validatePwdMsg != "valid-password") {
return;
}
$account_id = account_id_from_code($code);
$sql1 = "SELECT * FROM account_signup WHERE code='{$code}'";
$result = query($sql1);
if (mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_assoc($result);
$date_requested = $row["date_requested"];
$expires = $date_requested + 86400;
if (time() > $expires) {
echo "validation-expired";
return;
}
$encrypted_password = encrypt_password($password);
$sql2 = "UPDATE account_head SET status='logged-out' WHERE account={$account_id};";
query($sql2);
if (user_has_status($account_id, 'logged-out') == false) {
echo 'verify-error';
return;
}
$sql3 = "INSERT INTO account_credentials (account, username, password)";
$sql3 .= " VALUES ({$account_id}, '{$username}', '{$encrypted_password}');";
query($sql3);
if (user_has_credentials($account_id, $username, $encrypted_password) == false) {
echo 'verify-error';
return;
}
$sql4 = "DELETE FROM account_signup WHERE account={$account_id};";
query($sql4);
if (user_has_signup_pending($account_id)) {
echo 'verify-error';
return;
}
echo "verify-success";
return;
}
echo 'verify-error';
}
开发者ID:andrewdownie,项目名称:projectportfolio.io,代码行数:49,代码来源:verify_account.php
示例17: new_user
function new_user($user, $email, $password, $type)
{
validate_username($user);
validate_password($password);
$salt = sha1(time());
$hashed_pass = sha1($salt . $password);
$query = "INSERT INTO `users`
(`User_name`, `Password`, `Salt`, `Type`, `Ppal_email`)
VALUES ('@v','@v','@v', '@v', '@v')";
$this->query($query, $user, $hashed_pass, $salt, $type, $email);
}
开发者ID:robehickman,项目名称:Scripts,代码行数:15,代码来源:users.php
示例18: isValid
public function isValid($value)
{
if ($value == '') {
$this->setError(__('Please enter a username.', WPJB_DOMAIN));
return false;
} elseif (!validate_username($value)) {
$this->setError(__('This username is invalid because it uses illegal characters. Please enter a valid username.', WPJB_DOMAIN));
$value = '';
return false;
} elseif (username_exists($value)) {
$this->setError(__('This username is already registered, please choose another one.', WPJB_DOMAIN));
return false;
}
return true;
}
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:15,代码来源:Username.php
示例19: rhm_ajax_register
function rhm_ajax_register()
{
$user_login = '';
$user_email = '';
extract($_POST);
// Should include $user_login and $user_email.
$errors = new WP_Error();
$sanitized_user_login = sanitize_user($user_login);
$user_email = apply_filters('user_registration_email', $user_email);
// Check the username
if ($sanitized_user_login == '') {
$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
} elseif (!validate_username($user_login)) {
$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.'));
$sanitized_user_login = '';
} elseif (username_exists($sanitized_user_login)) {
$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered. Please choose another one.'));
}
// Check the e-mail address
if ($user_email == '') {
$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
} elseif (!is_email($user_email)) {
$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'));
$user_email = '';
} elseif (email_exists($user_email)) {
$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
}
do_action('register_post', $sanitized_user_login, $user_email, $errors);
$errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email);
if ($errors->get_error_code()) {
echo $errors->get_error_message();
die;
}
$user_pass = wp_generate_password(12, false);
$user_id = wp_create_user($sanitized_user_login, $user_pass, $user_email);
if (!$user_id) {
$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
echo $errors->get_error_message();
die;
}
update_user_option($user_id, 'default_password_nag', true, true);
//Set up the Password change nag.
wp_new_user_notification($user_id, $user_pass);
echo '<strong>Success!</strong> Your registration is complete. A randomly-generated password has been emailed to you.';
die;
}
开发者ID:Jcorona02,项目名称:gomexsi-web,代码行数:46,代码来源:functions.php
示例20: create_username
/**
*
* Create Username
*
* Creates a username from the given first name and last name. Format is first initial and last name. If username exists, adds an integer to the end of the username.
*
* @author Ryan Bagwell <[email protected]>
* @param string $first the person's first name
* @param string $last the person's last name
* @return the user name
*
*/
function create_username($first = null,$last = null) {
$name = strtolower(substr($first,0,1) . $last);
//if it's a valid combintion of their first initial and last name, retur
|
请发表评论