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

PHP wp_insert_user函数代码示例

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

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



在下文中一共展示了wp_insert_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: users

 /**
  * Generate users
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function users($args, $assoc_args)
 {
     global $blog_id;
     $defaults = array('count' => 100, 'role' => get_option('default_role'));
     extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
     if ('none' == $role) {
         $role = false;
     } elseif (is_null(get_role($role))) {
         WP_CLI::warning("invalid role.");
         exit;
     }
     $user_count = count_users();
     $total = $user_count['total_users'];
     $limit = $count + $total;
     $notify = new \cli\progress\Bar('Generating users', $count);
     for ($i = $total; $i < $limit; $i++) {
         $login = sprintf('user_%d_%d', $blog_id, $i);
         $name = "User {$i}";
         $user_id = wp_insert_user(array('user_login' => $login, 'user_pass' => $login, 'nickname' => $name, 'display_name' => $name, 'role' => $role));
         if (false === $role) {
             delete_user_option($user_id, 'capabilities');
             delete_user_option($user_id, 'user_level');
         }
         $notify->tick();
     }
     $notify->finish();
 }
开发者ID:bytewang,项目名称:wp-cli,代码行数:33,代码来源:generate.php


示例2: subscribe

 function subscribe()
 {
     global $videotube;
     $name = wp_filter_nohtml_kses($_POST['name']);
     $email = wp_filter_nohtml_kses($_POST['email']);
     $agree = wp_filter_nohtml_kses($_POST['agree']);
     $referer = wp_filter_nohtml_kses($_POST['referer']);
     $role = isset($videotube['subscribe_roles']) ? $videotube['subscribe_roles'] : 'subscriber';
     if (!$name) {
         echo json_encode(array('resp' => 'error', 'message' => __('Please enter your name.', 'mars'), 'id' => 'name'));
         exit;
     }
     if (!$email || !is_email($email)) {
         echo json_encode(array('resp' => 'error', 'message' => __('Please enter a valid email address.', 'mars'), 'id' => 'email'));
         exit;
     }
     if ($agree != true || $agree != 'true') {
         echo json_encode(array('resp' => 'error', 'message' => __('Please agree with our Private Policy.', 'mars'), 'id' => 'agree'));
         exit;
     }
     $user_id = wp_insert_user(array('user_login' => $email, 'user_email' => $email, 'display_name' => $name, 'user_pass' => wp_generate_password(6, true), 'role' => $role));
     if (is_wp_error($user_id)) {
         echo json_encode(array('resp' => 'error', 'message' => $user_id->get_error_message()));
         exit;
     }
     update_user_meta($user_id, 'referer', $referer);
     echo json_encode(array('resp' => 'success', 'message' => __('Congratulation.', 'mars'), 'redirect_to' => get_permalink($referer)));
     exit;
 }
开发者ID:chypriote,项目名称:wp-video,代码行数:29,代码来源:Mars_Subscribe_Ajax.php


示例3: ajax_register

function ajax_register()
{
    // First check the nonce, if it fails the function will break
    check_ajax_referer('ajax-register-nonce', 'security');
    // Nonce is checked, get the POST data and sign user on
    $info = array();
    $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']);
    $info['user_pass'] = sanitize_text_field($_POST['password']);
    $info['user_email'] = sanitize_email($_POST['email']);
    // Register the user
    $user_register = wp_insert_user($info);
    if (is_wp_error($user_register)) {
        $error = $user_register->get_error_codes();
        if (in_array('empty_user_login', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __('Xin lỗi, thông tin đăng nhập không hợp lệ.')));
        } else {
            if (in_array('existing_user_login', $error)) {
                echo json_encode(array('loggedin' => false, 'message' => __('Xin lỗi, tên đăng nhập này đã tồn tại.')));
            } else {
                if (in_array('existing_user_email', $error)) {
                    echo json_encode(array('loggedin' => false, 'message' => __('Xin lỗi, thư điện tử này đã tồn tại.')));
                }
            }
        }
        //        else echo json_encode(array('loggedin'=>false, 'message'=>__($user_register->get_error_messages($error))));
    } else {
        wp_insert_user($info);
        echo json_encode(array('loggedin' => true, 'message' => __('Đăng ký thành công.')));
    }
    die;
}
开发者ID:vinhvv75,项目名称:tutannet,代码行数:31,代码来源:ajax-auth.php


示例4: ajax_register

 /**
  * AJAX Register.
  *
  * @since 1.0.0
  */
 public function ajax_register()
 {
     // First check the nonce, if it fails the function will break
     check_ajax_referer('vr-ajax-register-nonce', 'vr-secure-register');
     // Nonce is checked, Get to work
     $info = array();
     $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['register_username']);
     $info['user_pass'] = sanitize_text_field($_POST['register_pwd']);
     $info['user_email'] = sanitize_email($_POST['register_email']);
     // Register the user
     $user_register = wp_insert_user($info);
     if (is_wp_error($user_register)) {
         $error = $user_register->get_error_codes();
         if (in_array('empty_user_login', $error)) {
             echo json_encode(array('success' => false, 'message' => __($user_register->get_error_message('empty_user_login'))));
         } elseif (in_array('existing_user_login', $error)) {
             echo json_encode(array('success' => false, 'message' => __('This username already exists.', 'VRC')));
         } elseif (in_array('existing_user_email', $error)) {
             echo json_encode(array('success' => false, 'message' => __('This email is already registered.', 'VRC')));
         }
     } else {
         /**
          * Object: VR_Member class.
          *
          * @since 1.0.0
          */
         $vr_member_object = new VR_Member();
         $vr_member_object->ajax_user_authenticate($info['user_login'], $info['user_pass'], __('Registration', 'VRC'));
     }
     die;
 }
开发者ID:WPTie,项目名称:VRCore,代码行数:36,代码来源:class-register.php


示例5: ajax_register

function ajax_register()
{
    // First check the nonce, if it fails the function will break
    check_ajax_referer('ajax-register-nonce', 'security');
    // Nonce is checked, get the POST data and sign user on
    $info = array();
    $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']);
    $info['user_pass'] = sanitize_text_field($_POST['password']);
    $info['user_email'] = sanitize_email($_POST['email']);
    // Register the user
    $user_register = wp_insert_user($info);
    if (is_wp_error($user_register)) {
        $error = $user_register->get_error_codes();
        if (in_array('empty_user_login', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __($user_register->get_error_message('empty_user_login'))));
        } elseif (in_array('existing_user_login', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __('This username is already registered.')));
        } elseif (in_array('existing_user_email', $error)) {
            echo json_encode(array('loggedin' => false, 'message' => __('This email address is already registered.')));
        }
    } else {
        auth_user_login($info['nickname'], $info['user_pass'], 'Registration');
    }
    die;
}
开发者ID:Vatia13,项目名称:dancesport,代码行数:25,代码来源:functions.php


示例6: ins_oauth

function ins_oauth()
{
    $code = $_GET['code'];
    $url = "https://api.instagram.com/oauth/access_token";
    $data = array('client_id' => INS_APPID, 'client_secret' => INS_APPSECRET, 'grant_type' => 'authorization_code', 'redirect_uri' => home_url('/?type=instagram'), 'code' => $code);
    $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
    $output = json_decode($response['body'], true);
    $token = $output['access_token'];
    $user = $output['user'];
    $ins_id = $user['id'];
    $name = $user['username'];
    if (!$ins_id) {
        wp_redirect(home_url('/?3' . $douban_id));
        exit;
    }
    if (is_user_logged_in()) {
        $this_user = wp_get_current_user();
        update_user_meta($this_user->ID, "instagram_id", $ins_id);
        ins_ouath_redirect();
    } else {
        $user_ins = get_users(array("meta_key " => "instagram_id", "meta_value" => $ins_id));
        if (is_wp_error($user_ins) || !count($user_ins)) {
            $login_name = wp_create_nonce($ins_id);
            $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
            $userdata = array('user_login' => $login_name, 'display_name' => $name, 'user_email' => '', 'user_pass' => $random_password, 'nick_name' => $name);
            $user_id = wp_insert_user($userdata);
            wp_signon(array("user_login" => $login_name, "user_password" => $random_password), false);
            update_user_meta($user_id, "instagram_id", $ins_id);
            ins_ouath_redirect();
        } else {
            wp_set_auth_cookie($user_ins[0]->ID);
            ins_ouath_redirect();
        }
    }
}
开发者ID:AlwaysOnline,项目名称:wp-oauth,代码行数:35,代码来源:instagram.php


示例7: qq_oauth

function qq_oauth()
{
    $code = $_GET['code'];
    $token_url = "https://graph.qq.com/oauth2.0/token?client_id=" . QQ_APPID . "&client_secret=" . QQ_APPSECRET . "&grant_type=authorization_code&redirect_uri=" . urlencode(home_url()) . "&code=" . $code;
    $response = wp_remote_get($token_url);
    $response = $response['body'];
    if (strpos($response, "callback") !== false) {
        wp_redirect(home_url());
    }
    $params = array();
    parse_str($response, $params);
    $qq_access_token = $params["access_token"];
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $qq_access_token;
    $str = wp_remote_get($graph_url);
    $str = $str['body'];
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str, true);
    if (isset($user->error)) {
        echo "<h3>错误代码:</h3>" . $user->error;
        echo "<h3>信息  :</h3>" . $user->error_description;
        exit;
    }
    $qq_openid = $user['openid'];
    if (!$qq_openid) {
        wp_redirect(home_url());
        exit;
    }
    $get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $qq_access_token . "&oauth_consumer_key=" . QQ_APPID . "&openid=" . $qq_openid . "&format=json";
    $data = wp_remote_get($get_user_info);
    $data = $data['body'];
    $data = json_decode($data, true);
    $username = $data['nickname'];
    $avatar = $data['figureurl_2'];
    if (is_user_logged_in()) {
        $this_user = wp_get_current_user();
        update_user_meta($this_user->ID, "qq_openid", $qq_openid);
        update_user_meta($this_user->ID, "qq_avatar", $avatar);
        fa_qq_oauth_redirect();
    } else {
        $user_qq = get_users(array("meta_key " => "qq_openid", "meta_value" => $qq_openid));
        if (is_wp_error($user_qq) || !count($user_qq)) {
            $login_name = wp_create_nonce($qq_openid);
            $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
            $userdata = array('user_login' => $login_name, 'display_name' => $username, 'user_pass' => $random_password, 'nick_name' => $username);
            $user_id = wp_insert_user($userdata);
            wp_signon(array("user_login" => $login_name, "user_password" => $random_password), false);
            update_user_meta($user_id, "qq_openid", $qq_openid);
            update_user_meta($user_id, "qq_avatar", $avatar);
            fa_qq_oauth_redirect();
        } else {
            wp_set_auth_cookie($user_qq[0]->ID);
            update_user_meta($user_qq[0]->ID, "qq_avatar", $avatar);
            fa_qq_oauth_redirect();
        }
    }
}
开发者ID:yarec,项目名称:wp-oauth,代码行数:60,代码来源:auth-qq.php


示例8: cr

function cr(&$fields, &$errors)
{
    // Check args and replace if necessary
    if (!is_array($fields)) {
        $fields = array();
    }
    if (!is_wp_error($errors)) {
        $errors = new WP_Error();
    }
    // Check for form submit
    if (isset($_POST['submit'])) {
        // Get fields from submitted form
        $fields = cr_get_fields();
        // Validate fields and produce errors
        if (cr_validate($fields, $errors)) {
            // If successful, register user
            wp_insert_user($fields);
            // And display a message
            echo 'Registration complete. Goto <a href="' . get_site_url() . '/wp-login.php">login page</a>.';
            // Clear field data
            $fields = array();
        }
    }
    // Santitize fields
    cr_sanitize($fields);
    // Generate form
    cr_display_form($fields, $errors);
}
开发者ID:anam5233,项目名称:wp_user_reg_plugin,代码行数:28,代码来源:first.php


示例9: testTwoUsersWithTheSameName

 function testTwoUsersWithTheSameName()
 {
     $user_id_1 = wp_insert_user(array('user_login' => 'mario_rossi', 'user_pass' => 'tmppass', 'first_name' => 'Mario', 'last_name' => 'Rossi'));
     $this->assertEquals($this->getURI('mario_rossi'), Wordlift_User_Service::get_instance()->get_uri($user_id_1));
     $user_id_2 = wp_insert_user(array('user_login' => 'mario_rossi_1', 'user_pass' => 'tmppass', 'first_name' => 'Mario', 'last_name' => 'Rossi'));
     $this->assertEquals($this->getURI('mario_rossi_1'), Wordlift_User_Service::get_instance()->get_uri($user_id_2));
 }
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:7,代码来源:test-user.php


示例10: userRegister

 function userRegister()
 {
     $this->verifyNonce('userRegister');
     $data = $_POST["data"];
     $userID = wp_insert_user(array('first_name' => $data["first_name"], 'last_name' => $data["last_name"], 'nickname' => $data["nickname"], 'user_email' => $data["user_email"], 'user_login' => $data["user_login"], 'user_pass' => $data["user_pass"]));
     /*
     	Add a custom capability to the user
     		$user = new WP_User($userID);
     		$user->add_cap("edit_posts");
     		$user->add_cap("delete_posts");
     */
     if (isset($userID->errors)) {
         echo json_encode($userID);
     } else {
         //Add USER INFO
         add_user_meta($userID, "adress", $data["adress"], true);
         add_user_meta($userID, "localidade", $data["localidade"], true);
         add_user_meta($userID, "codPostal", $data["codPostal"], true);
         add_user_meta($userID, "treinador", "Não atribuido", true);
         //Notify user and admin that a new user arrived
         wp_new_user_notification($userID, '', 'both');
         echo '{"userID": "' . $userID . '"}';
     }
     wp_die();
 }
开发者ID:eralha,项目名称:wp_angular_base,代码行数:25,代码来源:ajax__calls.php


示例11: registration

 public function registration($name, $pass, $email, $money)
 {
     $data = array('user_pass' => $pass, 'user_login' => $name, 'user_email' => $email, 'perfectmoney' => $money);
     #return ID new user
     $ret = wp_insert_user($data);
     #var_dump($ret);
 }
开发者ID:alexandrtkachuk,项目名称:arena,代码行数:7,代码来源:User.php


示例12: process_registration

 public function process_registration()
 {
     do_action('popmake_alm_ajax_override_registration');
     $user_login = $_POST['user_login'];
     $user_email = $_POST['user_email'];
     $user_pass = isset($_POST['user_pass']) ? $_POST['user_pass'] : wp_generate_password(12, false);
     $userdata = compact('user_login', 'user_email', 'user_pass');
     $user = wp_insert_user($userdata);
     if (!isset($_POST['user_pass'])) {
         update_user_option($user, 'default_password_nag', true, true);
         // Set up the Password change nag.
         wp_new_user_notification($user, $user_pass);
     }
     if (is_wp_error($user)) {
         $response = array('success' => false, 'message' => $user->get_error_message());
     } else {
         if (popmake_get_popup_ajax_registration($_POST['popup_id'], 'enable_autologin')) {
             $creds = array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true);
             $user = wp_signon($creds);
         }
         $message = __('Registration complete.', 'popup-maker-ajax-login-modals');
         if (!isset($_POST['user_pass'])) {
             $message .= ' ' . __('Please check your e-mail.', 'popup-maker-ajax-login-modals');
         }
         $response = array('success' => true, 'message' => $message);
     }
     echo json_encode($response);
     die;
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:29,代码来源:class-ajax.php


示例13: ucenter_oauth

function ucenter_oauth()
{
    //根据授权码获取access_token
    $url = UCENTER_API . '/oauth/accessToken';
    $data = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'grant_type' => 'authorization_code', 'redirect_uri' => REDIRECT_URI, 'code' => $_GET['code']);
    $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
    $data = json_decode($response['body'], true);
    if (1 !== $data['code']) {
        wp_die('授权失败');
    }
    $access_token = $data['data']['access_token'];
    //根据access_token获取用户信息
    $url = UCENTER_API . '/user/?access_token=' . $access_token;
    $data = wp_remote_get($url);
    $data = json_decode($data['body'], true);
    if (1 !== $data['code']) {
        wp_die('获取用户信息失败');
    }
    $username = $data['data']['username'];
    $user_id = $data['data']['user_id'];
    //根据返回的用户信息登录,用户还未存在时则插入
    $current_user = get_user_by('login', $username);
    if (is_wp_error($current_user) || !$current_user) {
        $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
        $user_id = wp_insert_user(array('user_login' => $username, 'display_name' => $username, 'nick_name' => $username, 'user_pass' => $random_password));
        wp_set_auth_cookie($user_id);
    } else {
        wp_set_auth_cookie($current_user->ID);
    }
    header('Location: ' . home_url() . '/wp-admin');
    exit;
}
开发者ID:yaoshanliang,项目名称:WordPress,代码行数:32,代码来源:wp-ucenter-login.php


示例14: usersExist

 /**
  * @Given /^Users exist:$/
  */
 public function usersExist(TableNode $table)
 {
     $usersData = $table->getHash();
     add_filter('send_password_change_email', '__return_false');
     add_filter('send_email_change_email', '__return_false');
     foreach ($usersData as $userData) {
         if (empty($userData['login'])) {
             throw new \InvalidArgumentException('You must provide a user login!');
         }
         $user = get_user_by('login', $userData['login']);
         $data = $this->getUserDataFromTable($userData);
         if ($user) {
             $data['ID'] = $user->ID;
         }
         $result = $user ? wp_update_user($data) : wp_insert_user($data);
         if (is_wp_error($result)) {
             throw new \UnexpectedValueException('User could not be created: ' . $result->get_error_message());
         }
         foreach ($this->getUserMetaDataFromTable($userData) as $key => $value) {
             update_user_meta($user->ID, $key, $value);
         }
     }
     remove_filter('send_password_change_email', '__return_false');
     remove_filter('send_email_change_email', '__return_false');
 }
开发者ID:johnpbloch,项目名称:WpBehatExtension,代码行数:28,代码来源:UserContext.php


示例15: create

 /**
  * Create a user
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function create($args, $assoc_args)
 {
     global $blog_id;
     $user_login = $args[0];
     $user_email = $args[1];
     if (!$user_login || !$user_email) {
         WP_CLI::error("Login and email required (see 'wp user help').");
     }
     $defaults = array('role' => get_option('default_role'), 'user_pass' => wp_generate_password(), 'user_registered' => strftime("%F %T", time()), 'display_name' => false);
     extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
     if ('none' == $role) {
         $role = false;
     } elseif (is_null(get_role($role))) {
         WP_CLI::error("Invalid role.");
     }
     $user_id = wp_insert_user(array('user_email' => $user_email, 'user_login' => $user_login, 'user_pass' => $user_pass, 'user_registered' => $user_registered, 'display_name' => $display_name, 'role' => $role));
     if (is_wp_error($user_id)) {
         WP_CLI::error($user_id);
     } else {
         if (false === $role) {
             delete_user_option($user_id, 'capabilities');
             delete_user_option($user_id, 'user_level');
         }
     }
     WP_CLI::success("Created user {$user_id}.");
 }
开发者ID:bytewang,项目名称:wp-cli,代码行数:32,代码来源:user.php


示例16: erp_hr_employee_create

/**
 * Create a new employee
 *
 * @param  array  arguments
 *
 * @return int  employee id
 */
function erp_hr_employee_create($args = array())
{
    global $wpdb;
    $defaults = array('user_email' => '', 'company_id' => erp_get_current_company_id(), 'work' => array('designation' => 0, 'department' => 0, 'location' => '', 'hiring_source' => '', 'hiring_date' => '', 'date_of_birth' => '', 'reporting_to' => 0, 'pay_rate' => '', 'pay_type' => '', 'type' => '', 'status' => ''), 'personal' => array('photo_id' => 0, 'user_id' => 0, 'first_name' => '', 'middle_name' => '', 'last_name' => '', 'other_email' => '', 'phone' => '', 'work_phone' => '', 'mobile' => '', 'address' => '', 'gender' => '', 'marital_status' => '', 'nationality' => '', 'driving_license' => '', 'hobbies' => '', 'user_url' => '', 'description' => ''));
    $posted = array_map('strip_tags_deep', $args);
    $posted = array_map('trim_deep', $posted);
    $data = wp_parse_args($posted, $defaults);
    // some basic validation
    if (empty($data['personal']['first_name'])) {
        return new WP_Error('empty-first-name', __('Please provide the first name.', 'wp-erp'));
    }
    if (empty($data['personal']['last_name'])) {
        return new WP_Error('empty-last-name', __('Please provide the last name.', 'wp-erp'));
    }
    if (!is_email($data['user_email'])) {
        return new WP_Error('invalid-email', __('Please provide a valid email address.', 'wp-erp'));
    }
    // attempt to create the user
    $password = wp_generate_password(12);
    $userdata = array('user_login' => $data['user_email'], 'user_pass' => $password, 'user_email' => $data['user_email'], 'first_name' => $data['personal']['first_name'], 'last_name' => $data['personal']['last_name'], 'display_name' => $data['personal']['first_name'] . ' ' . $data['personal']['last_name'], 'role' => 'employee');
    // if user id exists, do an update
    $user_id = isset($posted['user_id']) ? intval($posted['user_id']) : 0;
    $update = false;
    if ($user_id) {
        $update = true;
        $userdata['ID'] = $user_id;
    }
    $userdata = apply_filters('erp_hr_employee_args', $userdata);
    $user_id = wp_insert_user($userdata);
    if (is_wp_error($user_id)) {
        return $user_id;
    }
    // if reached here, seems like we have success creating the user
    $employee = new \WeDevs\ERP\HRM\Employee($user_id);
    // inserting the user for the first time
    if (!$update) {
        $work = $data['work'];
        if (!empty($work['type'])) {
            $employee->update_employment_status($work['type']);
        }
        // update compensation
        if (!empty($work['pay_rate'])) {
            $pay_type = !empty($work['pay_type']) ? $work['pay_type'] : 'monthly';
            $employee->update_compensation($work['pay_rate'], $pay_type);
        }
        // update job info
        $employee->update_job_info($work['department'], $work['designation'], $work['reporting_to'], $work['location']);
    }
    // update the erp table
    $wpdb->update($wpdb->prefix . 'erp_hr_employees', array('company_id' => (int) $data['company_id'], 'hiring_source' => $data['work']['hiring_source'], 'hiring_date' => $data['work']['hiring_date'], 'date_of_birth' => $data['work']['date_of_birth']), array('user_id' => $user_id));
    foreach ($data['personal'] as $key => $value) {
        update_user_meta($user_id, $key, $value);
    }
    if ($update) {
        do_action('erp_hr_employee_update', $user_id, $data);
    } else {
        do_action('erp_hr_employee_new', $user_id, $data);
    }
    return $user_id;
}
开发者ID:nizamuddin,项目名称:wp-erp,代码行数:67,代码来源:functions-employee.php


示例17: do_affiliates

 public function do_affiliates($step = 1)
 {
     global $wpdb;
     $offset = ($step - 1) * 100;
     $affiliates = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}affiliates_tbl LIMIT {$offset}, 100;");
     $to_delete = array();
     if ($affiliates) {
         foreach ($affiliates as $affiliate) {
             if (empty($affiliate->email)) {
                 continue;
             }
             $user = get_user_by('email', $affiliate->email);
             if (is_wp_error($user) || !$user) {
                 $user_id = wp_insert_user(array('user_email' => $affiliate->email, 'first_name' => $affiliate->firstname, 'last_name' => $affiliate->lastname, 'user_url' => $affiliate->website, 'user_pass' => '', 'user_login' => $affiliate->email));
             } else {
                 $user_id = $user->ID;
             }
             $payment_email = !empty($affiliate->paypalemail) ? $affiliate->paypalemail : $affiliate->email;
             $status = 'approved' == $affiliate->account_status ? 'active' : 'pending';
             $args = array('date_registered' => date('Y-n-d H:i:s', strtotime($affiliate->date)), 'user_id' => $user_id, 'payment_email' => $payment_email, 'rate' => $affiliate->commissionlevel, 'status' => $status);
             // Try to get an existing affiliate based on the user_id
             $existing_affiliate = affiliate_wp()->affiliates->get_by('user_id', $user_id);
             if ($existing_affiliate) {
                 continue;
             }
             // Insert a new affiliate - we need to always insert to make sure the affiliate_ids will match
             $id = affiliate_wp()->affiliates->insert($args, 'affiliate');
         }
         return true;
     } else {
         // No affiliates found, so all done
         return false;
     }
 }
开发者ID:nerrad,项目名称:AffiliateWP,代码行数:34,代码来源:class-migrate-wp-affiliate.php


示例18: setUp

	public function setUp() {
		parent::setUp();

		$user = wp_insert_user( array(
			'user_login' => 'test',
			'user_pass'       => 'pass',
			'first_name' => 'Tester',
			'user_email' => '[email protected]'
		) );

		$this->member = new RCP_Member( $user );

		$levels = new RCP_Levels;

		$this->level_id = $levels->insert( array(
			'name'          => 'Gold',
			'duration'      => 1,
			'duration_unit' => 'month',
			'level'         => 1,
			'status'        => 'active'
		) );

		$this->level_id_2 = $levels->insert( array(
			'name'          => 'Silver',
			'duration'      => 1,
			'duration_unit' => 'month',
			'status'        => 'active',
			'level'         => 3
		) );
	}
开发者ID:nciske,项目名称:Restrict-Content-Pro,代码行数:30,代码来源:test-members.php


示例19: member_add

function member_add($data_post=''){
	global $wpdb;
	$data = $_POST;
	unset($data['action'],$data['submit'],$data['ID']);
	
	$data['date_added'] = date( 'Y-m-d H:i:s');
	
	$wpdb->insert($wpdb->prefix . 'questions' , $data);
	$insert_id= $wpdb->insert_id;
	
	
	if(!empty($insert_id)){
		$report['text'] =  "New Successfully added. Saved under ID of <b>{$insert_id}</b>";
		$report['text'] .=  "<script>jQuery('#question-form').slideUp();</script>";
		$report['class'] = 'updated';
		$report['ID'] = $insert_id;
		
		$userdata = array(
			'user_pass' => esc_attr($ProfilePassword),
			'user_login' => esc_attr($ProfileUsername),
			'first_name' => esc_attr($ProfileContactNameFirst),
			'last_name' => esc_attr($ProfileContactNameLast),
			'user_email' => esc_attr($ProfileContactEmail),
			'role' => get_option('default_role')
		);
		$new_user = wp_insert_user( $userdata );
	}else{
		$report['text'] =  'Error: '.$wpdb->last_error;
		$report['class'] = 'error';
	}
	echo json_encode($report);
	exit();
	return;
}
开发者ID:xyren,项目名称:Site-Membership,代码行数:34,代码来源:ajax.php


示例20: add_new_employer

 function add_new_employer($postdata)
 {
     if (isset($postdata['employer_id']) && !empty($postdata['employer_id'])) {
         $user_id = $postdata['employer_id'];
         $this->update_empoyer($user_id, $postdata);
         return $user_id;
     }
     $validate = $this->new_admin_form_validate($postdata);
     if (is_wp_error($validate)) {
         return $validate;
     }
     $random_password = wp_generate_password(8, false);
     $first_name = sanitize_text_field($postdata['first_name']);
     $last_name = sanitize_text_field($postdata['last_name']);
     $display_name = $first_name . ' ' . $last_name;
     $userdata = array('user_login' => $postdata['user_name'], 'user_pass' => $random_password, 'user_email' => $postdata['email'], 'first_name' => $first_name, 'last_name' => $last_name, 'display_name' => $display_name, 'role' => 'hrm_employee');
     $user_id = wp_insert_user($userdata);
     if ($user_id) {
         update_user_meta($user_id, '_hrm_user_role', 'hrm_employee');
         $this->update_empoyer($user_id, $postdata);
         wp_new_user_notification($user_id, $random_password);
         return $user_id;
     } else {
         return false;
     }
 }
开发者ID:Ejeus,项目名称:Human-Resource-Management-hrm,代码行数:26,代码来源:employeelist.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_install函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_insert_term函数代码示例发布时间: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