本文整理汇总了PHP中username_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP username_exists函数的具体用法?PHP username_exists怎么用?PHP username_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了username_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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') {
if (username_exists($request_data['username'])) {
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:alvarpoon,项目名称:aeg,代码行数:30,代码来源:username.php
示例2: 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
示例3: checkauthor
function checkauthor($author)
{
global $wpdb;
//mtnames is an array with the names in the mt import file
$pass = 'changeme';
if (!in_array($author, $this->mtnames)) {
//a new mt author name is found
++$this->j;
$this->mtnames[$this->j] = $author;
//add that new mt author name to an array
$user_id = username_exists($this->newauthornames[$j]);
//check if the new author name defined by the user is a pre-existing wp user
if (!$user_id) {
//banging my head against the desk now.
if ($newauthornames[$this->j] == 'left_blank') {
//check if the user does not want to change the authorname
$user_id = wp_create_user($author, $pass);
$this->newauthornames[$this->j] = $author;
//now we have a name, in the place of left_blank.
} else {
$user_id = wp_create_user($this->newauthornames[$this->j], $pass);
}
} else {
return $user_id;
// return pre-existing wp username if it exists
}
} else {
$key = array_search($author, $this->mtnames);
//find the array key for $author in the $mtnames array
$user_id = username_exists($this->newauthornames[$key]);
//use that key to get the value of the author's name from $newauthornames
}
return $user_id;
}
开发者ID:robertlange81,项目名称:Website,代码行数:34,代码来源:mt.php
示例4: lls_authenticate
function lls_authenticate($user, $username)
{
// 1. Get all active session for this user
if (!username_exists($username) || !($user = get_user_by('login', $username))) {
return null;
}
// will trigger WP default no username/password matched error
// setup vars
$max_sessions = 5;
$max_oldest_allowed_session_hours = 4;
$error_code = 'max_session_reached';
$error_message = "Maximum {$max_sessions} login sessions are allowed. Please contact site administrator.";
$manager = WP_Session_Tokens::get_instance($user->ID);
$sessions = $manager->get_all();
// 2. Count all active session
$session_count = count($sessions);
// 3. Return okay if active session less then $max_sessions
if ($session_count < $max_sessions) {
return $user;
}
$oldest_activity_session = lls_get_oldest_activity_session($sessions);
// 4. If active sessions is equal to 5 then check if a session has no activity last 4 hours
// 5. if oldest session have activity return error
if ($session_count >= $max_sessions && !$oldest_activity_session || $session_count >= $max_sessions && $oldest_activity_session['last_activity'] + $max_oldest_allowed_session_hours * HOUR_IN_SECONDS > time()) {
return new WP_Error($error_code, $error_message);
}
// 5. Oldest activity session doesn't have activity is given recent hours
// destroy oldest active session and authenticate the user
$verifier = lls_get_verifier_by_session($oldest_activity_session, $user->ID);
lls_destroy_session($verifier, $user->ID);
return $user;
}
开发者ID:prionkor,项目名称:limit-login-sessions,代码行数:32,代码来源:limit-login-sessions.php
示例5: validate_signup
function validate_signup()
{
require_once WPPR_PLUGIN_DIR . '/models/signup-model.php';
$model = new Signup_Model();
if (username_exists($this->username)) {
return new WP_Error('username_unavailable', 'Username already taken');
}
if (!validate_username($this->username)) {
// invalid username
return new WP_Error('username_invalid', 'Username is invalid');
}
if (strlen($this->username) < 4) {
return new WP_Error('username_length', 'Username too short. At least 4 characters is required');
}
if (!is_email($this->email)) {
return new WP_Error('email_invalid', 'Email is not valid');
}
if (email_exists($this->email)) {
return new WP_Error('email', 'Email is already in used.');
}
if ($model->validate_email($this->email)) {
return new WP_Error('email', 'You already used this email to signup. Please check your email for confirmation.');
}
if (strlen($this->password) <= 5) {
return new WP_Error('password_too_short', 'Password is too short.');
}
}
开发者ID:owliber,项目名称:pr-membership,代码行数:27,代码来源:pr-signup-controller.php
示例6: validate_form_saved
function validate_form_saved($fields)
{
if (isset($_POST['submit'])) {
$current_user = wp_get_current_user();
$user_email = $_POST['user_email'];
// receiving email address
//Si cambio de usuario y existe es error y no continua
if ($current_user->user_email != $_POST['user_email'] && username_exists($user_email) != false) {
?>
<script>
jQuery(document).on('ready', function(){
jQuery("#emailErr").html("Intenta con otro email, este ya está registrado");
jQuery("#emailErr").show();
}); </script>
<?php
return;
}
//Actualiza los daos basicos
$current_user->user_email = $user_email;
$current_user->user_login = $user_email;
$current_user->first_name = $_POST['user_first_name'];
wp_update_user($current_user);
//Recorre todos los campos del formulario y valida
foreach ($fields as $field) {
$keyfield = sanitize_key($field->Name) . "_" . $field->Id;
update_user_meta($current_user->ID, sanitize_key($field->Name), $_POST[$keyfield], $current_user->get(sanitize_key($field->Name)));
}
}
}
开发者ID:betocastillo86,项目名称:bicimensajeria,代码行数:29,代码来源:UpdateUserData.php
示例7: um_submit_form_errors_hook_login
function um_submit_form_errors_hook_login($args)
{
global $ultimatemember;
$is_email = false;
$form_id = $args['form_id'];
$mode = $args['mode'];
if (isset($args['username']) && $args['username'] == '') {
$ultimatemember->form->add_error('username', __('Please enter your username or email', 'ultimatemember'));
}
if (isset($args['user_login']) && $args['user_login'] == '') {
$ultimatemember->form->add_error('user_login', __('Please enter your username', 'ultimatemember'));
}
if (isset($args['user_email']) && $args['user_email'] == '') {
$ultimatemember->form->add_error('user_email', __('Please enter your email', 'ultimatemember'));
}
if (isset($args['username'])) {
$field = 'username';
if (is_email($args['username'])) {
$is_email = true;
$data = get_user_by('email', $args['username']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$user_name = $args['username'];
}
} else {
if (isset($args['user_email'])) {
$field = 'user_email';
$is_email = true;
$data = get_user_by('email', $args['user_email']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$field = 'user_login';
$user_name = $args['user_login'];
}
}
if (!username_exists($user_name)) {
if ($is_email) {
$ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that email address', 'ultimatemember'));
} else {
$ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that username', 'ultimatemember'));
}
} else {
if ($args['user_password'] == '') {
$ultimatemember->form->add_error('user_password', __('Please enter your password', 'ultimatemember'));
}
}
$user = get_user_by('login', $user_name);
if ($user && wp_check_password($args['user_password'], $user->data->user_pass, $user->ID)) {
$ultimatemember->login->auth_id = username_exists($user_name);
} else {
$ultimatemember->form->add_error('user_password', __('Password is incorrect. Please try again.', 'ultimatemember'));
}
// add a way for other plugins like wp limit login
// to limit the login attempts
$user = apply_filters('authenticate', null, $user_name, $args['user_password']);
// if there is an error notify wp
if ($ultimatemember->form->has_error($field) || $ultimatemember->form->has_error($user_password)) {
do_action('wp_login_failed', $user_name);
}
}
开发者ID:jonfalcon,项目名称:ultimatemember,代码行数:60,代码来源:um-actions-login.php
示例8: wp_install
/**
* Installs the blog
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Will default to a random password.
* @param string $language Optional. Language chosen.
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
if ($language) {
update_option('WPLANG', $language);
}
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
/*
* Create default user. If the user already exists, the user tables are
* being shared among blogs. Just set the role in that case.
*/
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
// Password has been provided
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
} else {
$message = __('User already exists. Password inherited.');
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
/**
* Fires after a site is fully installed.
*
* @since 3.9.0
*
* @param WP_User $user The site owner.
*/
do_action('wp_install', $user);
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:76,代码来源:upgrade.php
示例9: test_add_a_guardian
public function test_add_a_guardian()
{
$guardian_id = username_exists('sam');
$this->plugin->addGuardian($guardian_id, get_current_user_id());
$this->assertTrue(in_array($guardian_id, get_user_meta(get_current_user_id(), 'better-angels_guardians')));
return $guardian_id;
}
开发者ID:adagaria,项目名称:better-angels,代码行数:7,代码来源:test-guardians.php
示例10: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '')
{
global $wp_rewrite;
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = wp_generate_password();
$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
}
开发者ID:alx,项目名称:blogsfera,代码行数:34,代码来源:upgrade.php
示例11: 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
示例12: bp_activity_find_mentions
/**
* Searches through the content of an activity item to locate usernames,
* designated by an @ sign.
*
* @since BuddyPress (1.5)
*
* @param string $content The content of the activity, usually found in $activity->content.
* @return mixed Associative array with user ID as key and username as value. Boolean false if no mentions found.
*/
function bp_activity_find_mentions($content)
{
$pattern = '/[@]+([A-Za-z0-9-_\\.@]+)\\b/';
preg_match_all($pattern, $content, $usernames);
// Make sure there's only one instance of each username
if (!($usernames = array_unique($usernames[1]))) {
return false;
}
$mentioned_users = array();
// We've found some mentions! Check to see if users exist
foreach ((array) $usernames as $key => $username) {
if (bp_is_username_compatibility_mode()) {
$user_id = username_exists($username);
} else {
$user_id = bp_core_get_userid_from_nicename($username);
}
// user ID exists, so let's add it to our array
if (!empty($user_id)) {
$mentioned_users[$user_id] = $username;
}
}
if (empty($mentioned_users)) {
return false;
}
return $mentioned_users;
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:35,代码来源:bp-activity-functions.php
示例13: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $meta = '')
{
global $wp_rewrite;
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
$guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = substr(md5(uniqid(microtime())), 0, 6);
$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:35,代码来源:upgrade-functions.php
示例14: user_register
public function user_register()
{
global $wpdb;
$data = $_POST;
$login_data = array();
$resp = new ajax_response($data['action'], true);
$code_data = $wpdb->get_results('SELECT * FROM ' . $wpdb->register_codes . ' WHERE 1=1 AND register_code == ' . $wpdb->escape($data['sec_code']));
if ($code_data->register_code_used == 0) {
$username = $wpdb->escape($data['user_name']);
$exists = username_exists($username);
if (!$exists) {
$user_id = wp_create_user($username, wp_generate_password($length = 12, $include_standard_special_chars = false), $username);
wp_new_user_notification($user_id, null, true);
if (!is_wp_error($user_id)) {
$user = get_user_by('id', $user_id);
$wpdb->update($wpdb->register_codes, array('register_code_used' => 1, 'register_code_used_by' => $user->data->user_login), array('register_code' => $wpdb->escape($data['sec_code'])));
$resp->set_status(true);
$resp->set_message($user->data->user_login . ' is successfully registered. Please switch to the login tab to login.');
} else {
foreach ($user_id->errors as $k => $error) {
$resp->set_message(array($error[0]));
}
}
} else {
$resp->set_message('User already exists. Please use a different email address.');
}
} else {
$resp->set_message('Security token not recognized. Could not register you without a valid security token.');
}
echo $resp->encode_response();
die;
}
开发者ID:TrevorMW,项目名称:wp-lrsgen,代码行数:32,代码来源:class-custom-login.php
示例15: acxu_createUser
function acxu_createUser($args)
{
global $wp_xmlrpc_server;
$wp_xmlrpc_server->escape($args);
$nickname = $args[0];
//$password = $args[1];
//if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) )
// return $wp_xmlrpc_server->error;
$user_name = time() . "_" . rand(1000, 9999);
$user_email = $user_name . "@bbuser.org";
if (!username_exists($user_name) && !email_exists($user_email)) {
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
$user_id = wp_create_user($user_name, $random_password, $user_email);
if ($nickname == "") {
$nickname = $user_email;
}
// Update the user to set the nickname
wp_update_user(array('ID' => $user_id, 'nickname' => $nickname));
// Get the user object to set the user's role
$wp_user_object = new WP_User($user_id);
//http://en.support.wordpress.com/user-roles/
$wp_user_object->set_role('author');
return $user_name . " " . $random_password;
} else {
return "ERROR: User Name or Email Already Exists";
}
}
开发者ID:AurangZ,项目名称:securereader,代码行数:27,代码来源:auto-create-xmlrpc-user.php
示例16: confirm_email
function confirm_email($user, $key)
{
require_once WPPR_PLUGIN_DIR . '/models/signup-model.php';
$model = new Signup_Model();
if (isset($_GET['key']) && !empty($_GET['key']) && isset($_GET['user']) && !empty($_GET['user'])) {
//Sanitize keys
$model->key = sanitize_key($_GET['key']);
$model->user = sanitize_user($_GET['user']);
$result = $model->validate_key();
if ($result !== false && !username_exists($model->user)) {
$userdata = array($model->user, $model->user, $result['signup_password'], $result['signup_email'], $result['signup_date'], $model->user);
//Transfer record from wp_signup table to wp_users
$confirmed = $model->register_user($userdata);
if ($confirmed) {
// Notify admin of new registration
//wp_new_user_notification( $result );
echo $this->redirect_on_success();
} else {
echo $this->redirect_on_error();
}
} else {
echo $this->redirect_on_error();
}
}
}
开发者ID:owliber,项目名称:pr-membership,代码行数:25,代码来源:pr-confirm-email-controller.php
示例17: user_login
function user_login($username, $password)
{
$res_arr = array();
if (empty($username) || empty($password)) {
$res_arr['errormsg'] = 'Required field is missing';
return $res_arr;
//return $errors;
}
$user_id = username_exists($username);
$user = user_pass_ok($username, $password);
if (!empty($user_id)) {
$user_data = get_userdata($user_id);
if ($user == 1) {
$res_arr['Id'] = $user_id;
$res_arr['username'] = $username;
return $res_arr;
} else {
$res_arr['errormsg'] = 'Invalid password';
return $res_arr;
}
} else {
$res_arr['errormsg'] = 'Invalid username';
return $res_arr;
}
}
开发者ID:aditdeveloper,项目名称:stageLocal,代码行数:25,代码来源:login.php
示例18: test_getMyGuardians
function test_getMyGuardians()
{
// Survivor's guardian list should start empty.
$this->assertEquals(array(), $this->plugin->getMyGuardians());
// After adding a guardian, which is a user that
// must actually exist, then the current user's
// guardian list should include that user.
$this->plugin->addGuardian('sam');
$expected = array(get_userdata(username_exists('sam')));
$this->assertEquals($expected, $this->plugin->getMyGuardians());
// Adding the same guardian again should not result
// in a duplicate guardian.
$this->plugin->addGuardian('sam');
$this->assertEquals($expected, $this->plugin->getMyGuardians());
// Let's add another guardian for good measure.
$this->plugin->addGuardian('john');
$expected = array_merge($expected, array(get_userdata(username_exists('john'))));
$this->assertEquals($expected, $this->plugin->getMyGuardians());
// Removing a guardian should remove them from
// the list of guardians retrieved.
$this->plugin->removeGuardian('sam');
array_shift($expected);
$this->assertEquals($expected, $this->plugin->getMyGuardians());
// 'john' should still be a guardian, as he was
// added but not removed.
$this->assertTrue($this->plugin->isMyGuardian('john'));
// This means there should be 1 and only 1 guardian
// in the list.
$this->assertCount(1, $this->plugin->getMyGuardians());
}
开发者ID:vangogh72,项目名称:better-angels,代码行数:30,代码来源:test-guardians.php
示例19: wp_install
/**
* Installs the blog
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param null $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Will default to a random password.
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
if (!is_file(ABSPATH . 'wp-admin/install.sql')) {
//[ysd]如果有install.sql不设置默认options数据
populate_options();
} else {
validate_active_plugins();
//[ysd] 禁用 不可用的插件
}
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = isset($_SERVER['HTTP_APPNAME']) ? 'http://' . substr($_SERVER['HTTP_APPNAME'], 5) . '.1kapp.com' : wp_guess_url();
//[ysd] 固定了guessurl
update_option('siteurl', $guessurl);
update_option('home', $guessurl);
get_option('siteurl');
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
// Password has been provided
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
} else {
$message = __('User already exists. Password inherited.');
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
if (!file_exists(ABSPATH . 'wp-admin/without_default')) {
wp_install_defaults($user_id);
}
//[ysd],如果打包时设置了默认数据,才会设置默认数据
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
开发者ID:ramo01,项目名称:1kapp,代码行数:74,代码来源:upgrade.php
示例20: generate_unique_username
/**
* Function generate_unique_username
*/
function generate_unique_username($term_name, $count = '')
{
if (!username_exists($term_name . $count)) {
return $term_name . $count;
}
$count = $count == '' ? 1 : absint($count) + 1;
$this->generate_unique_username($term_name, $count);
}
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:11,代码来源:class-wcmp-taxonomy.php
注:本文中的username_exists函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论