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

PHP wp_update_user函数代码示例

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

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



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

示例1: doUpdateRecord

function doUpdateRecord($data)
{
    $email = $_POST['crg_login_email'];
    $user = get_user_by('email', $email);
    $content = $_POST['notes'];
    $title = $_POST['Last_Name'] . ", " . $_POST['First_Name'];
    $userdata = array('ID' => $user->ID, 'first_name' => $_POST['First_Name'], 'last_name' => $_POST['Last_Name']);
    $returnValue = wp_update_user($userdata);
    $form = get_page_by_title($title, 'OBJECT', 'InfoForm');
    if ($form) {
        $my_post = array('ID' => $form->ID, 'post_title' => $title, 'post_author' => $user->ID, 'post_content' => $content, 'post_type' => 'InfoForm');
        wp_update_post($my_post);
        foreach ($data as $k => $v) {
            update_post_meta($form->ID, $k, $v);
        }
    } else {
        $my_post = array('post_title' => $title, 'post_content' => $content, 'post_author' => $user->ID, 'post_type' => 'InfoForm');
        // Insert the post into the database
        $form_id = wp_insert_post($my_post);
        foreach ($data as $k => $v) {
            add_post_meta($form_id, $k, $v);
        }
        $link = "/info-sheet/?user=" . $user->ID;
        $admin_email = get_bloginfo('admin_email');
        $subject = 'New Info Form';
        $body = get_site_url() . $link;
        $headers = 'From: ' . $title . ' <' . $email . '>' . "\r\n";
        wp_mail($admin_email, $subject, $body, $headers);
    }
}
开发者ID:Hitman007,项目名称:ArcticColdCapsMods,代码行数:30,代码来源:doUpdateRecord.php


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


示例3: update_user

 /**
  * Updates user data
  *
  * @return (array)
  */
 public function update_user($user_id)
 {
     $input = $this->input();
     $user['ID'] = $user_id;
     if (!(defined('IS_WPCOM') && IS_WPCOM)) {
         foreach ($input as $key => $value) {
             if (!is_array($value)) {
                 $value = trim($value);
             }
             $value = wp_unslash($value);
             switch ($key) {
                 case 'first_name':
                 case 'last_name':
                     $user[$key] = $value;
                     break;
                 case 'display_name':
                 case 'name':
                     $user['display_name'] = $value;
                     break;
             }
         }
     }
     if (isset($input['roles'])) {
         if (is_array($input['roles'])) {
             $user['role'] = $input['roles'][0];
         } else {
             $user['role'] = $input['roles'];
         }
     }
     $result = wp_update_user($user);
     if (is_wp_error($result)) {
         return $result;
     }
     return $this->get_user($user_id);
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:40,代码来源:class.wpcom-json-api-site-user-endpoint.php


示例4: process_change_profile_form

 /**
  * Process change profile form
  *
  * @access public
  * @return void
  */
 public static function process_change_profile_form()
 {
     if (!isset($_POST['change_profile_form'])) {
         return;
     }
     $user = wp_get_current_user();
     $nickname = $_POST['nickname'];
     $email = $_POST['email'];
     $first_name = $_POST['first_name'];
     $last_name = $_POST['last_name'];
     if (empty($nickname)) {
         $_SESSION['messages'][] = array('warning', __('Nickname is required.', 'realia'));
         return;
     }
     if (empty($email)) {
         $_SESSION['messages'][] = array('warning', __('E-mail is required.', 'realia'));
         return;
     }
     update_user_meta($user->ID, 'nickname', $nickname);
     update_user_meta($user->ID, 'user_email', $email);
     wp_update_user(array('ID' => $user->ID, 'user_email' => $email));
     update_user_meta($user->ID, 'last_name', $last_name);
     update_user_meta($user->ID, 'first_name', $first_name);
     $_SESSION['messages'][] = array('success', __('Profile has been successfully updated.', 'realia'));
 }
开发者ID:jhonrsalcedo,项目名称:sitio,代码行数:31,代码来源:class-realia-post-type-user.php


示例5: scramble_password

 private function scramble_password()
 {
     if ($this->options['scramble_passwords'] && $this->new_user == false) {
         $this->user->user_pass = wp_hash_password(wp_generate_password(12, true, true));
         wp_update_user($user);
     }
 }
开发者ID:justinoue,项目名称:SSOPress,代码行数:7,代码来源:sso.php


示例6: authenticate

 /**
  *  Authenticates the user using SAML
  *
  *  @return void
  */
 public function authenticate()
 {
     if (isset($_GET['loggedout']) && $_GET['loggedout'] == 'true') {
         header('Location: ' . get_option('siteurl'));
         exit;
     } elseif ($this->settings->get_allow_sso_bypass() == true && (isset($_GET['use_sso']) && $_GET['use_sso'] == 'false' || isset($_POST['use_sso']) && $_POST['use_sso'] == 'false')) {
         // User wants native WP login, do nothing
     } else {
         $redirect_url = array_key_exists('redirect_to', $_GET) ? wp_login_url($_GET['redirect_to']) : get_admin_url();
         $this->saml->requireAuth(array('ReturnTo' => $redirect_url));
         $attrs = $this->saml->getAttributes();
         if (array_key_exists($this->settings->get_attribute('username'), $attrs) && array_key_exists($this->settings->get_attribute('email'), $attrs)) {
             $username = $attrs[$this->settings->get_attribute('username')][0];
             $email = $attrs[$this->settings->get_attribute('email')][0];
             if (get_user_by('login', $username)) {
                 //$this->simulate_signon($username);
                 // FIX https://wordpress.org/support/topic/passwords-of-existing-users-not-working-how-to-update#post-6835783
                 require_once ABSPATH . WPINC . '/ms-functions.php';
                 $user = get_user_by('login', $username);
                 if ($user) {
                     $newpass = $this->user_password($username, $this->secretsauce);
                     wp_set_password($newpass, $user->ID);
                     wp_update_user(array('ID' => $user->ID, 'user_email' => $email));
                 }
                 $this->simulate_signon($username);
             } else {
                 $this->new_user($attrs);
             }
         } else {
             die('A username and email was not provided. ' . $this->support_message);
         }
     }
 }
开发者ID:pajtai,项目名称:saml-20-single-sign-on-alt,代码行数:38,代码来源:saml_client.php


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


示例8: registerDefaultColorSchema

 /**
  * Register the default color schmea for every new registered user
  * 
  * @param int $userId the user id
  */
 public function registerDefaultColorSchema($userId)
 {
     $setting = $this->getOptions();
     if ($setting['default']) {
         wp_update_user(array('ID' => $userId, 'admin_color' => $setting['default']));
     }
 }
开发者ID:hyyan,项目名称:admin-color-schema,代码行数:12,代码来源:HyyanAdminColorSchema.php


示例9: updateProfileInformation

 static function updateProfileInformation($data)
 {
     global $_js_helper;
     $success = 0;
     if (!$_js_helper->is_logged()) {
         return false;
     }
     $args = wp_parse_args($data, array());
     if ($args['edit_task'] && $args['edit_task'] == 'change_password') {
         $current_user = JS_Helper::get_current_js_user();
         if (!wp_check_password($args['old_pass'], $current_user->user_pass, $current_user->ID)) {
             return -2;
         }
     }
     $meta_data = $args['meta'];
     unset($args['meta']);
     if (!is_wp_error(wp_update_user($args))) {
         $success++;
     }
     if ($meta_data) {
         foreach ($meta_data as $meta_key => $meta_value) {
             $success += update_user_meta($args['ID'], $meta_key, $meta_value) ? 1 : 0;
         }
     }
     return strval($success);
 }
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:26,代码来源:class.user.php


示例10: run_update_method

 public function run_update_method($token = null)
 {
     $response = new OAuth2\Response();
     if (!isset($token['user_id']) || $token['user_id'] == 0) {
         $response->setError(400, 'invalid_request', 'Missing or invalid access token');
         $response->send();
         exit;
     }
     $user_id =& $token['user_id'];
     if (!current_user_can('edit_user', $user_id)) {
         $response->setError(400, 'invalid_request', 'You are not allowed to edit this user');
         $response->send();
         exit;
     }
     $user_id = wp_update_user(array('ID' => $user_id, 'display_name' => sanitize_text_field($_POST['name'])));
     if (is_wp_error($user_id)) {
         // There was an error, probably that user doesn't exist.
         $response->setError(400, 'invalid_request', 'There was an error updating me');
         $response->send();
         exit;
     } else {
         $return = array('success' => 'updated-me');
         $response = new OAuth2\Response($return);
         $response->send();
         exit;
     }
 }
开发者ID:wlcdesigns,项目名称:PHP-OAuth2,代码行数:27,代码来源:index.php


示例11: update_field_value

 public function update_field_value($object_id, $field_id, $value)
 {
     if (!in_array($field_id, self::$VALID_FIELDS)) {
         return;
     }
     wp_update_user(array('ID' => $object_id, $field_id => $value));
 }
开发者ID:Darkers54,项目名称:eLEGO,代码行数:7,代码来源:user-storage.class.php


示例12: rcl_confirm_user_registration

function rcl_confirm_user_registration()
{
    global $wpdb, $rcl_options;
    $reglogin = $_GET['rglogin'];
    $regpass = $_GET['rgpass'];
    $regcode = md5($reglogin);
    if ($regcode == $_GET['rgcode']) {
        if ($user = get_user_by('login', $reglogin)) {
            wp_update_user(array('ID' => $user->ID, 'role' => get_option('default_role')));
            $time_action = current_time('mysql');
            $action = $wpdb->get_var($wpdb->prepare("SELECT time_action FROM " . RCL_PREF . "user_action WHERE user = '%d'", $user->ID));
            if (!$action) {
                $wpdb->insert(RCL_PREF . 'user_action', array('user' => $user->ID, 'time_action' => $time_action));
            }
            $creds = array();
            $creds['user_login'] = $reglogin;
            $creds['user_password'] = $regpass;
            $creds['remember'] = true;
            $sign = wp_signon($creds, false);
            if (!is_wp_error($sign)) {
                rcl_update_timeaction_user();
                do_action('rcl_confirm_registration', $user->ID);
                wp_redirect(rcl_get_authorize_url($user->ID));
                exit;
            }
        }
    }
    if ($rcl_options['login_form_recall'] == 2) {
        wp_safe_redirect('wp-login.php?checkemail=confirm');
    } else {
        wp_redirect(get_bloginfo('wpurl') . '?action-rcl=login&error=confirm');
    }
    exit;
}
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:34,代码来源:register.php


示例13: palo_action_register

/**
 * Sets the user password 
 */
function palo_action_register($user_id)
{
    $userdata = array();
    $userdata['ID'] = $user_id;
    $userdata['user_pass'] = $_POST['palo_password'];
    wp_update_user($userdata);
}
开发者ID:gvh1993,项目名称:project-vvvh,代码行数:10,代码来源:login.php


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


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

 function set_default_admin_color($user_id)
 {
     $default_color = ub_get_option('ucs_default_color_scheme', false);
     if ($default_color && $default_color !== 'false') {
         $args = array('ID' => $user_id, 'admin_color' => $default_color);
         wp_update_user($args);
     }
 }
开发者ID:Bhabrooo,项目名称:aiesec-website-wordpress,代码行数:8,代码来源:ultimate-color-schemes.php


示例17: testUserWithoutFirstAndLastName

 function testUserWithoutFirstAndLastName()
 {
     $user_id = wp_insert_user(array('user_login' => 'lorem_ipsum', 'user_pass' => 'tmppass'));
     $this->assertEquals($this->getURI('lorem_ipsum'), Wordlift_User_Service::get_instance()->get_uri($user_id));
     $update_user_id = wp_update_user(array('ID' => $user_id, 'user_login' => 'lorem_ipsum', 'user_pass' => 'tmppass', 'first_name' => 'Lorem', 'last_name' => 'Ipsum'));
     $this->assertEquals($update_user_id, $user_id);
     $this->assertEquals($this->getURI('lorem_ipsum'), Wordlift_User_Service::get_instance()->get_uri($user_id));
 }
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:8,代码来源:test-user.php


示例18: testGetStudentName

 /**
  * Test the "get_student_name" method.
  */
 public function testGetStudentName()
 {
     $edr_crt = Edr_Manager::get('edr_crt');
     $student = get_user_by('id', 1);
     $this->assertEquals($student->display_name, $edr_crt->get_student_name($student));
     wp_update_user(array('ID' => $student->ID, 'first_name' => 'FirstName', 'last_name' => 'LastName'));
     $this->assertEquals('FirstName LastName', $edr_crt->get_student_name($student));
 }
开发者ID:educatorplugin,项目名称:educator-certificates,代码行数:11,代码来源:test-edr-crt.php


示例19: update

 /**
  * Update the user properties.
  *
  * @param array $userdata
  * @return \Themosis\User\User|\WP_Error
  */
 public function update(array $userdata)
 {
     $userdata = array_merge($userdata, ['ID' => $this->ID]);
     $user = wp_update_user($userdata);
     if (is_wp_error($user)) {
         return $user;
     }
     return $this;
 }
开发者ID:johnulist,项目名称:framework,代码行数:15,代码来源:User.php


示例20: px_verify_view_registration_page

function px_verify_view_registration_page()
{
    global $errors;
    $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
    if ($http_post) {
        $action = $_POST['wp-submit'];
        $code = esc_attr($_POST['purchase_code']);
        $verify = px_verify_purchase($code);
        if ($action == 'Register') {
            if (!is_wp_error($verify)) {
                $user_login = $_POST['user_login'];
                $user_email = $_POST['user_email'];
                $errors = register_new_user($user_login, $user_email);
                if (!is_wp_error($errors)) {
                    $user_id = $errors;
                    $pxarr1 = px_verify_globals(1);
                    $pxarr2 = px_verify_globals(2);
                    $pxarr2 = array_keys($pxarr2);
                    if ($verify['px_envato_item'] == $pxarr1['item1']) {
                        wp_update_user(array('ID' => $user_id, 'role' => $pxarr2[0]));
                    } else {
                        if ($verify['px_envato_item'] == $pxarr1['item2']) {
                            wp_update_user(array('ID' => $user_id, 'role' => $pxarr2[1]));
                        } else {
                            wp_update_user(array('ID' => $user_id, 'role' => 'bbp_blocked'));
                        }
                    }
                    do_action('px_verifier_user_registration', $user_id, $verify);
                    update_user_meta($user_id, 'px_envato_username', $verify['px_envato_username']);
                    update_user_meta($user_id, 'px_envato_purchase_date', $verify['px_envato_purchase_date']);
                    update_user_meta($user_id, 'px_envato_purchase_code', $verify['px_envato_purchase_code']);
                    update_user_meta($user_id, 'px_envato_license', $verify['px_envato_license']);
                    update_user_meta($user_id, 'px_envato_item', $verify['px_envato_item']);
                    update_user_meta($user_id, 'px_envato_support_amount', $verify['px_envato_support_amount']);
                    update_user_meta($user_id, 'px_envato_support_until', $verify['px_envato_support_until']);
                    $redirect_to = 'wp-login.php?checkemail=registered';
                    wp_safe_redirect($redirect_to);
                    exit;
                } else {
                    px_verify_view_registration_form($errors, $verify);
                }
            } else {
                px_verify_view_verification_form($verify);
            }
        } elseif ($action == 'Verify') {
            if (!is_wp_error($verify)) {
                px_verify_view_registration_form($errors, $verify);
            } else {
                px_verify_view_verification_form($verify);
            }
        }
    } else {
        px_verify_view_verification_form();
    }
    px_verify_custom_style();
    exit;
}
开发者ID:pixelartdev,项目名称:Pixelart-Verifier,代码行数:57,代码来源:login.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_upgrade函数代码示例发布时间: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