• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_create_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_create_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_create_user函数的具体用法?PHP wp_create_user怎么用?PHP wp_create_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_create_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:34,代码来源:ofsocial.php


示例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);
    }
}
开发者ID:kamilik26,项目名称:aiesec,代码行数:13,代码来源:users.php


示例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;
 }
开发者ID:TrevorMW,项目名称:wp-lrsgen,代码行数:32,代码来源:class-custom-login.php


示例4: setUp

 public function setUp()
 {
     parent::setUp();
     global $wpdb;
     // Current a test user and make them current.
     $tester = get_user_by('email', '[email protected]');
     if (!$tester) {
         $tester_id = wp_create_user('tester', 'test123', '[email protected]');
     } 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);
 }
开发者ID:kcdipesh,项目名称:tabulate,代码行数:27,代码来源:TestBase.php


示例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);
}
开发者ID:ravasthi,项目名称:web-base-template,代码行数:35,代码来源:install.php


示例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);
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:35,代码来源:upgrade-functions.php


示例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));
        }
    }
}
开发者ID:liroyti,项目名称:Jinnilotto,代码行数:27,代码来源:page-user.php


示例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;
 }
开发者ID:uicestone,项目名称:TingHaoWan,代码行数:33,代码来源:weixin-api.php


示例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', '[email protected]');
     $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.');
 }
开发者ID:pra85,项目名称:sensei,代码行数:30,代码来源:test-class-lesson.php


示例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);
 }
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:76,代码来源:upgrade.php


示例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);
 }
开发者ID:alx,项目名称:blogsfera,代码行数:34,代码来源:upgrade.php


示例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;
}
开发者ID:smithsa,项目名称:daily-job-hunter,代码行数:33,代码来源:um-actions-register.php


示例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;
 }
开发者ID:robertlange81,项目名称:Website,代码行数:34,代码来源:mt.php


示例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> ';
}
开发者ID:WHTGo,项目名称:EXP-Training,代码行数:7,代码来源:RegisterWP.php


示例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);
 }
开发者ID:patchdotworks,项目名称:patchchat,代码行数:46,代码来源:class-patchchat-controller.php


示例16: 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


示例17: registrar_usuario

function registrar_usuario($parametros)
{
    $errors = new WP_Error();
    if ($parametros['email'] == NULL) {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
        return $errors;
    }
    if (!es_email($parametros['email'])) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
        return $errors;
    }
    if (email_exists($parametros['email'])) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
        return $errors;
    }
    if ($parametros['nombre'] == NULL) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
        return $errors;
    }
    $user_pass = $parametros['clave'] == NULL ? wp_generate_password(12, false) : $parametros['clave'];
    $user_id = wp_create_user($parametros['email'], $user_pass, $parametros['email']);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
        return $errors;
    }
    update_user_option($user_id, 'default_password_nag', true, true);
    //Set up the Password change nag.
    wp_new_user_notification($user_id, $user_pass);
    // Actualización de tabla clientes...
    return $user_id;
}
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:31,代码来源:acciones.php


示例18: testGetTermAuthor

 /**
  * Testing Sensei_Core_Modules::get_term_author
  */
 public function testGetTermAuthor()
 {
     // setup assertions
     $test_user_id = wp_create_user('teacherGetTermAuthor', 'teacherGetTermAuthor', '[email protected]');
     //insert a general term
     wp_insert_term('Get Started', 'module');
     //insert a term as if from the user
     wp_insert_term('Get Started Today', 'module', array('description' => 'A yummy apple.', 'slug' => $test_user_id . '-get-started-today'));
     // does the function exist?
     $this->assertTrue(method_exists('Sensei_Core_Modules', 'get_term_authors'), 'The function Sensei_Core_Modules::get_term_author does not exist ');
     // does the taxonomy exist
     $module_taxonomy = get_taxonomy('module');
     $this->assertTrue($module_taxonomy->public, 'The module taxonomy is not loaded');
     // does it return empty array id for bogus term nam?
     $term_authors = Sensei_Core_Modules::get_term_authors('bogusnonexistan');
     $this->assertTrue(empty($term_authors), 'The function should return false for an invalid term');
     //does it return the admin user for a valid term ?
     $admin = get_user_by('email', get_bloginfo('admin_email'));
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started');
     $this->assertTrue($admin == $term_authors[0], 'The function should return admin user for normal module term.');
     // does it return the expected new user for the given term registered with that id in front of the slug?
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started Today');
     $this->assertTrue(get_userdata($test_user_id) == $term_authors[0], 'The function should admin user for normal module term.');
     // what about terms with the same name but different slug?
     // It should return 2 authors as we've created 2 with the same name
     // insert a term that is the same as the first one
     wp_insert_term('Get Started', 'module', array('description' => 'A yummy apple.', 'slug' => $test_user_id . '-get-started'));
     $term_authors = Sensei_Core_Modules::get_term_authors('Get Started');
     $this->assertTrue(2 == count($term_authors), 'The function should admin user for normal module term.');
 }
开发者ID:pra85,项目名称:sensei,代码行数:33,代码来源:test-class-modules.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: newAction

 public function newAction()
 {
     if (!get_option('users_can_register')) {
         $this->view->_flash->addError(__("User registration is disabled.", WPJB_DOMAIN));
         return false;
     }
     if ($this->_isCandidate()) {
         return false;
     }
     if ($this->_isLoggedIn()) {
         wp_redirect(wpjb_link_to("employer_panel"));
         return;
     }
     if (Wpjb_Model_Employer::current()->isEmployer()) {
         $this->view->_flash->addError(__("You need to be registered as Candidate in order to access this page. Your current account type is Employer.", WPJB_DOMAIN));
         return false;
     }
     $this->_setTitle(__("Register Employer", WPJB_DOMAIN));
     $form = new Wpjb_Form_Frontend_Register();
     $this->view->errors = array();
     if ($this->isPost()) {
         $isValid = $form->isValid($this->getRequest()->getAll());
         if ($isValid) {
             $username = $form->getElement("user_login")->getValue();
             $password = $form->getElement("user_password")->getValue();
             $email = $form->getElement("user_email")->getValue();
             $id = wp_create_user($username, $password, $email);
             $val = $form->getValues();
             update_usermeta($id, "is_employer", 1);
             $employer = new Wpjb_Model_Employer();
             $employer->user_id = $id;
             $employer->company_name = $val["company_name"];
             $employer->company_website = $val["company_website"];
             $employer->company_info = $val["company_info"];
             $employer->company_location = $val["company_location"];
             $employer->is_public = $val["is_public"];
             $employer->save();
             $instance = Wpjb_Project::getInstance();
             $router = $instance->getApplication("frontend")->getRouter();
             /* @var $router Daq_Router */
             $url = $instance->getApplication("frontend")->getUrl();
             $url .= "/" . $router->linkTo("employer_login");
             $mail = new Wpjb_Utility_Message(9);
             $mail->setTo($email);
             $mail->setParam("username", $username);
             $mail->setParam("password", $password);
             $mail->setParam("login_url", $url);
             $mail->send();
             $form = new Wpjb_Form_Login();
             $form->isValid(array("user_login" => $username, "user_password" => $password, "remember" => false));
             $this->view->_flash->addInfo(__("You have been registered successfully", WPJB_DOMAIN));
             $redirect = wpjb_link_to("employer_panel");
             wp_redirect($redirect);
         }
     }
     $this->view->form = $form;
     return "company-new";
 }
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:58,代码来源:Employer.php



注:本文中的wp_create_user函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_credits函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_create_thumbnail函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap