本文整理汇总了PHP中wp_create_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_create_user函数的具体用法?PHP wp_create_user怎么用?PHP wp_create_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_create_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openfire_authenticate
function openfire_authenticate($user, $username, $password)
{
global $openfire;
$openfire->of_logInfo("openfire_authenticate 1 " . $username . " " . $password);
if (!openfire_wants_to_login()) {
return new WP_Error('user_logged_out', sprintf(__('You are now logged out of Azure AD.', AADSSO), $username));
}
// Don't re-authenticate if already authenticated
if (strrpos($username, "@") == false || is_a($user, 'WP_User')) {
return $user;
}
$openfire->of_logInfo("openfire_authenticate 2 ");
// Try to find an existing user in WP where the UPN of the current AAD user is
// (depending on config) the 'login' or 'email' field
if ($username && $password && $openfire->of_authenticate_365($username, $password)) {
$user = get_user_by("email", $username);
if (!is_a($user, 'WP_User')) {
$openfire->of_logInfo("openfire_authenticate 3");
// Since the user was authenticated with AAD, but not found in WordPress,
// need to decide whether to create a new user in WP on-the-fly, or to stop here.
$openfire->of_logInfo("openfire_authenticate 4");
$paras = explode("@", $username);
$userid = $paras[0] . "." . $paras[1];
$new_user_id = wp_create_user($userid, $password, $username);
$user = new WP_User($new_user_id);
$user->set_role('subscriber');
$first_name = $openfire->of_get_given_name();
$last_name = $openfire->get_family_name();
$display_name = $first_name . " " . $last_name;
wp_update_user(array('ID' => $new_user_id, 'display_name' => $display_name, 'first_name' => $first_name, 'last_name' => $last_name));
}
}
return $user;
}
示例2: create_usuario_cuervo
/**
* Crear un nuevo usuario
* @param string $user username
*/
function create_usuario_cuervo($user)
{
$password = wp_generate_password();
$user_id = wp_create_user($user, $password, "{$user}@pcuervo.com");
if (is_int($user_id)) {
set_cuervo_role($user_id);
wp_new_user_notification($user_id, $password);
}
}
示例3: 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;
}
示例4: setUp
public function setUp()
{
parent::setUp();
global $wpdb;
// Current a test user and make them current.
$tester = get_user_by('email', 'test@example.com');
if (!$tester) {
$tester_id = wp_create_user('tester', 'test123', 'test@example.com');
} else {
$tester_id = $tester->ID;
}
wp_set_current_user($tester_id);
// Get the database.
$this->wpdb = $wpdb;
// Prevent parent from enforcing TEMPORARY tables.
remove_filter('query', array($this, '_create_temporary_tables'));
remove_filter('query', array($this, '_drop_temporary_tables'));
// Activate.
do_action('activate_tabulate/tabulate.php');
// Create some testing tables and link them together.
$this->wpdb->query('DROP TABLE IF EXISTS `test_table`');
$this->wpdb->query('CREATE TABLE `test_table` (' . ' id INT(10) AUTO_INCREMENT PRIMARY KEY,' . ' title VARCHAR(100) NOT NULL,' . ' description TEXT NULL,' . ' active BOOLEAN NULL DEFAULT TRUE,' . ' a_date DATE NULL,' . ' a_year YEAR NULL,' . ' type_id INT(10) NULL DEFAULT NULL,' . ' widget_size DECIMAL(10,2) NOT NULL DEFAULT 5.6,' . ' ranking INT(3) NULL DEFAULT NULL' . ');');
$this->wpdb->query('DROP TABLE IF EXISTS `test_types`');
$this->wpdb->query('CREATE TABLE `test_types` (' . ' id INT(10) AUTO_INCREMENT PRIMARY KEY,' . ' title VARCHAR(100) NOT NULL' . ');');
$this->wpdb->query('ALTER TABLE `test_table` ' . ' ADD FOREIGN KEY ( `type_id` )' . ' REFERENCES `test_types` (`id`)' . ' ON DELETE CASCADE ON UPDATE CASCADE;');
$this->db = new WordPress\Tabulate\DB\Database($this->wpdb);
}
示例5: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
global $wpdb;
$base = '/';
$domain = JQUERY_STAGING_PREFIX . 'jquery.com';
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
$user_id = wp_create_user($user_name, trim($user_password), $user_email);
$user = new WP_User($user_id);
$user->set_role('administrator');
$guess_url = wp_guess_url();
foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) {
$wpdb->{$table} = $prefixed_table;
}
install_network();
populate_network(1, $domain, $user_email, 'jQuery Network', $base, false);
update_site_option('site_admins', array($user->user_login));
update_site_option('allowedthemes', array());
$wpdb->insert($wpdb->blogs, array('site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time('mysql')));
$blog_id = $wpdb->insert_id;
update_user_meta($user_id, 'source_domain', $domain);
update_user_meta($user_id, 'primary_blog', $blog_id);
if (!($upload_path = get_option('upload_path'))) {
$upload_path = substr(WP_CONTENT_DIR, strlen(ABSPATH)) . '/uploads';
update_option('upload_path', $upload_path);
}
update_option('fileupload_url', get_option('siteurl') . '/' . $upload_path);
jquery_install_remaining_sites($user);
wp_new_blog_notification($blog_title, $guess_url, $user_id, $message = __('The password you chose during the install.'));
wp_cache_flush();
return array('url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
示例6: 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);
}
示例7: registerUser
function registerUser()
{
if (isset($_POST['FullName']) && isset($_POST['InputPasswordSignup']) && isset($_POST['InputEmailSignup'])) {
/**
* @var \WegeTech\LottoYard\Service $lottoService
*/
global $lottoService;
$user = new User();
$name = explode(' ', $_POST['FullName']);
$user->FirstName = htmlspecialchars($name[0]);
$user->LastName = htmlspecialchars($name[1]);
$user->Email = $_POST['InputEmailSignup'];
$user->IP = $_SERVER['REMOTE_ADDR'];
$response = $lottoService->signUpUser($user);
if ($response->success) {
$userResponse = wp_create_user($_POST['InputEmailSignup'], $_POST['InputPasswordSignup'], $_POST['InputEmailSignup']);
if (is_wp_error($userResponse)) {
wp_send_json(array('message' => $userResponse->get_error_message()));
}
add_user_meta($userResponse, 'lottoPass', $response->data->Password, true);
loginUser($_POST['InputEmailSignup'], $_POST['InputPasswordSignup']);
wp_send_json(array('data' => $response->data));
} else {
wp_send_json(array('message' => $response->message));
}
}
}
示例8: loggin
/**
* 根据open_id自动在系统中查找或注册用户,并获得微信用户信息
* 仅在用户与公众账号发生消息交互的时候才可以使用
*/
function loggin($open_id)
{
$users = get_users(array('meta_key' => 'wx_openid', 'meta_value' => $open_id));
if (!$users) {
$user_info = $this->get_user_info($open_id);
$user_id = wp_create_user($user_info->nickname, $open_id);
add_user_meta($user_id, 'wx_openid', $open_id, true);
add_user_meta($user_id, 'sex', $user_info->sex, true);
add_user_meta($user_id, 'country', $user_info->country, true);
add_user_meta($user_id, 'province', $user_info->province, true);
add_user_meta($user_id, 'language', $user_info->language, true);
add_user_meta($user_id, 'headimgurl', $user_info->headimgurl, true);
add_user_meta($user_id, 'subscribe_time', $user_info->subscribe_time, true);
} else {
$user_id = $users[0]->ID;
if ($users[0]->user_login === substr($open_id, -8, 8)) {
$user_info = $this->get_user_info($open_id);
update_user_meta($user_id, 'nickname', $user_info->nickname);
add_user_meta($user_id, 'sex', $user_info->sex, true);
add_user_meta($user_id, 'country', $user_info->country, true);
add_user_meta($user_id, 'province', $user_info->province, true);
add_user_meta($user_id, 'language', $user_info->language, true);
add_user_meta($user_id, 'headimgurl', $user_info->headimgurl, true);
add_user_meta($user_id, 'subscribe_time', $user_info->subscribe_time, true);
}
}
wp_set_current_user($user_id);
return $user_id;
}
示例9: testIsPreRequisiteComplete
/**
* Testing the is lesson pre-requisite completed function.
*
* @since 1.9.0
*/
public function testIsPreRequisiteComplete()
{
// does this function add_user_data exist?
$this->assertTrue(method_exists('WooThemes_Sensei_Lesson', 'is_prerequisite_complete'), 'The lesson class function `is_prerequisite_complete` does not exist ');
// falsy state
$user_id = 0;
$lesson_id = 0;
$this->assertFalse(WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id), 'None existing lesson or user should return false');
$test_user_id = wp_create_user('studentPrerequisite', 'studentPrerequisite', 'studentPrerequisite@test.com');
$test_lesson = $this->factory->get_lessons();
$test_lesson_id = $test_lesson[0];
// truthy state
$course_id = $this->factory->get_random_course_id();
$lessons = $this->factory->get_lessons();
$test_lesson_prerequisite_id = $lessons[1];
// add lesson to random course
update_post_meta($test_lesson_prerequisite_id, '_lesson_course', $course_id);
update_post_meta($test_lesson_id, '_lesson_course', $course_id);
// setup prerequisite
update_post_meta($test_lesson_id, '_lesson_prerequisite', $test_lesson_prerequisite_id);
Sensei_Utils::user_start_lesson($test_user_id, $test_lesson_prerequisite_id);
$this->assertFalse(WooThemes_Sensei_Lesson::is_prerequisite_complete($test_lesson_id, $test_user_id), 'Users that has NOT completeded prerequisite should return false.');
Sensei_Utils::user_start_lesson($test_user_id, $test_lesson_prerequisite_id, true);
$this->assertTrue(Sensei_Lesson::is_prerequisite_complete($test_lesson_id, $test_user_id), 'Users that has completeded prerequisite should return true.');
}
示例10: 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);
}
示例11: 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);
}
示例12: um_add_user_frontend
function um_add_user_frontend($args)
{
global $ultimatemember;
extract($args);
if (isset($user_email) && !isset($user_login)) {
$user_login = $user_email;
}
if (isset($username) && !isset($args['user_login'])) {
$user_login = $username;
}
if (isset($username) && is_email($username)) {
$user_email = $username;
}
if (!isset($user_password)) {
$user_password = $ultimatemember->validation->generate();
}
$unique_userID = $ultimatemember->query->count_users() + 1;
if (!isset($user_email)) {
$user_email = 'nobody' . $unique_userID . '@' . get_bloginfo('name');
}
if (!isset($user_login)) {
$user_login = 'user' . $unique_userID;
}
$creds['user_login'] = $user_login;
$creds['user_password'] = $user_password;
$creds['user_email'] = $user_email;
$args['submitted'] = array_merge($args['submitted'], $creds);
$args = array_merge($args, $creds);
do_action('um_before_new_user_register', $args);
$user_id = wp_create_user($user_login, $user_password, $user_email);
do_action('um_after_new_user_register', $user_id, $args);
return $user_id;
}
示例13: 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;
}
示例14: register_complete
function register_complete()
{
global $username, $email, $password;
$userdata = array('user_login' => $username, 'user_pass' => $password, 'user_email' => $email);
$user = wp_create_user($username, $password, $email);
//echo ' Register Complete. Goto: <a href=" '.get_site_url().'/wp-login.php">Login Page</a> ';
}
示例15: create
/**
* Creates a patchchat post by
* creating a user,
* creating a new patchchat post,
* creating first comment to post,
* adding an 'instant reply' comment from admin,
* building a new transient,
* return new transient to new user
*
* @author caseypatrickdriscoll
*
* @edited 2015-08-03 16:32:16 - Adds user signon after creation
* @edited 2015-08-28 20:11:39 - Adds PatchChat_Settings::instant_reply
* @edited 2015-08-28 20:19:22 - Adds PatchChat_Settings::bot
*/
public static function create($patchchat)
{
$email = $patchchat['email'];
$text = $patchchat['text'];
$username = substr($email, 0, strpos($email, "@"));
$password = wp_generate_password(10, false);
$title = substr($text, 0, 40);
$time = current_time('mysql');
$text = wp_strip_all_tags($text);
/* Create User */
$user_id = wp_create_user($username, $password, $email);
// TODO: Add the user's name to the user
// TODO: Check to see if user logged in, no need to create again
wp_new_user_notification($user_id, $password);
$user = get_user_by('id', $user_id);
$creds = array('user_login' => $user->user_login, 'user_password' => $password, 'remember' => true);
$user_signon = wp_signon($creds, false);
/* Create PatchChat Post */
$post = array('post_title' => $title, 'post_type' => 'patchchat', 'post_author' => $user_id, 'post_status' => 'new', 'post_date' => $time);
$post_id = wp_insert_post($post);
/* Create First Comment */
$comment = array('comment_post_ID' => $post_id, 'user_id' => $user_id, 'comment_content' => $text, 'comment_date' => $time, 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_agent' => $_SERVER['HTTP_USER_AGENT']);
$comment_id = wp_insert_comment($comment);
/* Insert default action comment reply */
$options = array('chatid' => $post_id, 'displayname' => $user->display_name);
$comment = array('comment_post_ID' => $post_id, 'user_id' => PatchChat_Settings::bot(), 'comment_content' => PatchChat_Settings::instant_reply($options), 'comment_type' => 'auto', 'comment_date' => current_time('mysql'));
$comment_id = wp_insert_comment($comment);
// Will build the Transient
PatchChat_Transient::get($post_id);
return PatchChat_Controller::get_user_state($user_id);
}