当前位置: 首页>>代码示例>>PHP>>正文


PHP clean_user_cache函数代码示例

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


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

示例1: wp_user_profiles_update_user_status

/**
 * Update the status of a user in the database.
 *
 * @since 0.1.3
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $user       The user.
 * @param string $pref       The column in the wp_users table to update the user's status
 *                           in (presumably user_status, spam, or deleted).
 * @param int    $value      The new status for the user.
 *
 * @return int   The initially passed $value.
 */
function wp_user_profiles_update_user_status($user, $status = 'inactive')
{
    global $wpdb;
    // Get the user
    $user = new WP_User($user);
    // Save the old status for help with transitioning
    $old_status = $user->user_status;
    // Update user status accordingly
    if ('spam' === $status) {
        $wpdb->update($wpdb->users, array('user_status' => '1', 'spam' => '1'), array('ID' => $user->ID));
    } elseif ('ham' === $status) {
        $wpdb->update($wpdb->users, array('user_status' => '0', 'spam' => '0'), array('ID' => $user->ID));
    } elseif ('deleted' === $status) {
        $wpdb->update($wpdb->users, array('user_status' => '2', 'deleted' => '1'), array('ID' => $user->ID));
    } elseif ('undeleted' === $status) {
        $wpdb->update($wpdb->users, array('user_status' => '0', 'deleted' => '0'), array('ID' => $user->ID));
    } elseif ('inactive' === $status) {
        $wpdb->update($wpdb->users, array('user_status' => '2', 'spam' => '0', 'deleted' => '0'), array('ID' => $user->ID));
    } else {
        $wpdb->update($wpdb->users, array('user_status' => '0', 'spam' => '0', 'deleted' => '0'), array('ID' => $user->ID));
    }
    // Bust the user's cache
    clean_user_cache($user);
    // Get the user, again
    $user = new WP_User($user);
    // Backpat for multisite
    if ('spam' === $status) {
        do_action('make_spam_user', $user->ID);
    } elseif ('active' === $status) {
        do_action('make_ham_user', $user->ID);
    }
    // Transition a user from one status to another
    wp_user_profiles_transition_user_status($user->user_status, $old_status, $user);
    return $user;
}
开发者ID:LaconicTranslator,项目名称:wp-user-profiles,代码行数:49,代码来源:status.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     // There's a bug in the multisite tests that causes the
     // transaction rollback to fail for the first user created,
     // which busts every other attempt to create users. This is a
     // hack workaround.
     global $wpdb;
     if (is_multisite()) {
         $user_1 = get_user_by('login', 'user 1');
         if ($user_1) {
             $wpdb->delete($wpdb->users, array('ID' => $user_1->ID));
             clean_user_cache($user_1);
         }
     }
     $this->factory = new BBP_UnitTest_Factory();
     if (class_exists('BP_UnitTest_Factory')) {
         $this->bp_factory = new BP_UnitTest_Factory();
     }
     // Our default is ugly permalinks, so reset when needed.
     global $wp_rewrite;
     if ($wp_rewrite->permalink_structure) {
         $this->set_permalink_structure();
     }
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:25,代码来源:testcase.php

示例3: block

 /**
  * Block User
  *
  * @return boolean
  *
  * @access public
  * @global wpdb $wpdb
  */
 public function block()
 {
     global $wpdb;
     $response = false;
     if (current_user_can('edit_users') && $this->getId() != get_current_user_id()) {
         $status = $this->getSubject()->user_status == 0 ? 1 : 0;
         if ($wpdb->update($wpdb->users, array('user_status' => $status), array('ID' => $this->getId()))) {
             $this->getSubject()->user_status = $status;
             clean_user_cache($this->getSubject());
             $response = true;
         }
     }
     return $response;
 }
开发者ID:Nguyenkain,项目名称:strida.vn,代码行数:22,代码来源:user.php

示例4: setInvalidPasswordForUser

 /**
  * Set a custom password after registration.
  *
  * @param WP_User  $user  WordPress user object
  * @return WP_User
  */
 public static function setInvalidPasswordForUser($user)
 {
     if (self::isAmazonOnlyUser($user)) {
         global $wpdb;
         $pass = 'LOGINWITHAMAZON00000000000000000';
         $wpdb->update('wp_users', array('user_pass' => $pass), array('ID' => $user->ID), array('%s'), array('%d'));
         clean_user_cache($user);
         return self::findUserByEmail($user->user_email);
     }
     return $user;
 }
开发者ID:amzn,项目名称:login-with-amazon-wordpress,代码行数:17,代码来源:utility.php

示例5: refresh_user_details

function refresh_user_details( $id ) {
	$id = (int) $id;

	if ( !$user = get_userdata( $id ) )
		return false;

	clean_user_cache( $id );

	return $id;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:10,代码来源:ms.php

示例6: wp_delete_user

/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since unknown
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    clean_user_cache($id);
    // FINALLY, delete user
    if (!is_multisite()) {
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->users} WHERE ID = %d", $id));
    } else {
        $level_key = $wpdb->get_blog_prefix() . 'capabilities';
        // wpmu site admins don't have user_levels
        $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE user_id = {$id} AND meta_key = '{$level_key}'");
    }
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
开发者ID:laiello,项目名称:cartonbank,代码行数:53,代码来源:user.php

示例7: handle_profile_modifications

 /**
  * Handles Profile modifications.
  *
  * @package s2Member\Profiles
  * @since 3.5
  *
  * @attaches-to ``add_action('init');``
  */
 public static function handle_profile_modifications()
 {
     global $current_user;
     // We'll need to update this global object.
     $user =& $current_user;
     // Shorter reference to the $current_user object.
     do_action('ws_plugin__s2member_before_handle_profile_modifications', get_defined_vars());
     if (!empty($_POST['ws_plugin__s2member_profile_save']) && is_user_logged_in() && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         if (($nonce = $_POST['ws_plugin__s2member_profile_save']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-profile-save')) {
             $GLOBALS['ws_plugin__s2member_profile_saved'] = TRUE;
             // Global flag as having been saved/updated successfully.
             $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST));
             // Clean ``$_POST`` vars.
             $userdata['ID'] = $user_id;
             // Needed for database update.
             if (!empty($_p['ws_plugin__s2member_profile_email'])) {
                 if (is_email($_p['ws_plugin__s2member_profile_email']) && !email_exists($_p['ws_plugin__s2member_profile_email'])) {
                     $userdata['user_email'] = $_p['ws_plugin__s2member_profile_email'];
                     if (strcasecmp($userdata['user_email'], $user->user_email) !== 0) {
                         $email_change = TRUE;
                     }
                 }
             }
             if (!empty($_p['ws_plugin__s2member_profile_password1'])) {
                 if ($user->user_login !== 'demo') {
                     // No pass change on demo!
                     $userdata['user_pass'] = $_p['ws_plugin__s2member_profile_password1'];
                 }
             }
             if (!empty($_p['ws_plugin__s2member_profile_first_name'])) {
                 $userdata['first_name'] = $_p['ws_plugin__s2member_profile_first_name'];
             }
             if (!empty($_p['ws_plugin__s2member_profile_display_name'])) {
                 $userdata['display_name'] = $_p['ws_plugin__s2member_profile_display_name'];
             }
             if (!empty($_p['ws_plugin__s2member_profile_last_name'])) {
                 $userdata['last_name'] = $_p['ws_plugin__s2member_profile_last_name'];
             }
             wp_update_user(wp_slash($userdata));
             // OK. Now send this array for an update.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                 if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level('auto-detection', 'profile')) {
                     $fields = array();
                     // Initialize the array of fields.
                     $_existing_fields = get_user_option('s2member_custom_fields', $user_id);
                     foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                         $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                         $field_id_class = preg_replace('/_/', '-', $field_var);
                         if (!in_array($field['id'], $fields_applicable) || strpos($field['editable'], 'no') === 0) {
                             if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                 $fields[$field_var] = $_existing_fields[$field_var];
                             } else {
                                 unset($fields[$field_var]);
                             }
                         } else {
                             if ($field['required'] === 'yes' && (!isset($_p['ws_plugin__s2member_profile_' . $field_var]) || !is_array($_p['ws_plugin__s2member_profile_' . $field_var]) && !is_string($_p['ws_plugin__s2member_profile_' . $field_var]) || is_array($_p['ws_plugin__s2member_profile_' . $field_var]) && empty($_p['ws_plugin__s2member_profile_' . $field_var]) || is_string($_p['ws_plugin__s2member_profile_' . $field_var]) && !strlen($_p['ws_plugin__s2member_profile_' . $field_var])) || isset($_p['ws_plugin__s2member_profile_' . $field_var]) && c_ws_plugin__s2member_custom_reg_fields::validation_errors(array($field_var => $_p['ws_plugin__s2member_profile_' . $field_var]), array($field))) {
                                 if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                     $fields[$field_var] = $_existing_fields[$field_var];
                                 } else {
                                     unset($fields[$field_var]);
                                 }
                             } else {
                                 if (isset($_p['ws_plugin__s2member_profile_' . $field_var])) {
                                     if ((is_array($_p['ws_plugin__s2member_profile_' . $field_var]) && !empty($_p['ws_plugin__s2member_profile_' . $field_var]) || is_string($_p['ws_plugin__s2member_profile_' . $field_var]) && strlen($_p['ws_plugin__s2member_profile_' . $field_var])) && !c_ws_plugin__s2member_custom_reg_fields::validation_errors(array($field_var => $_p['ws_plugin__s2member_profile_' . $field_var]), array($field))) {
                                         $fields[$field_var] = $_p['ws_plugin__s2member_profile_' . $field_var];
                                     } else {
                                         unset($fields[$field_var]);
                                     }
                                 } else {
                                     unset($fields[$field_var]);
                                 }
                             }
                         }
                     }
                     if (!empty($fields)) {
                         update_user_option($user_id, 's2member_custom_fields', $fields);
                     } else {
                         // Else delete their Custom Fields?
                         delete_user_option($user_id, 's2member_custom_fields');
                     }
                 }
             }
             foreach (array_keys(get_defined_vars()) as $__v) {
                 $__refs[$__v] =& ${$__v};
             }
             do_action('ws_plugin__s2member_during_handle_profile_modifications', get_defined_vars());
             unset($__refs, $__v);
             clean_user_cache($user_id);
             wp_cache_delete($user_id, 'user_meta');
             $user = new WP_User($user_id);
             // Fresh object.
             if (function_exists('setup_userdata')) {
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:profile-mods-in.inc.php

示例8: delete

 /**
  * Deletes this user.
  *
  * @note In the case of a multisite network installation of WordPress®,
  *    this will simply remove the user from the current blog (e.g. they're NOT actually deleted).
  *
  * @param null|integer $reassign_posts_to_user_id Optional. A user ID to which any posts will be reassigned.
  *    If this is NULL (which it is by default), all posts will simply be deleted, along with the user.
  *
  * @return boolean|errors TRUE if the user is deleted, else an errors object on failure.
  *
  * @throws exception If invalid types are passed through arguments list.
  * @throws exception If this user does NOT have an ID (e.g. we CANNOT delete them).
  */
 public function delete($reassign_posts_to_user_id = NULL)
 {
     $this->check_arg_types(array('null', 'integer:!empty'), func_get_args());
     if (!$this->has_id()) {
         throw $this->©exception($this->method(__FUNCTION__) . '#id_missing', array_merge(get_defined_vars(), array('user' => $this)), $this->__('User has no ID (cannot delete).'));
     }
     if ($this->is_super_admin()) {
         return $this->©error($this->method(__FUNCTION__) . '#super_admin', array_merge(get_defined_vars(), array('user' => $this)), sprintf($this->__('Cannot delete super administrator: `%1$s`.'), $this->username));
     }
     if (!wp_delete_user($this->ID, $reassign_posts_to_user_id)) {
         return $this->©error($this->method(__FUNCTION__) . '#failure', array_merge(get_defined_vars(), array('user' => $this)), sprintf($this->__('Failed to delete user ID: `%1$s`.'), $this->ID));
     }
     $this->do_action('delete', $this, array_merge(get_defined_vars(), array('user' => $this)));
     $ID = $this->ID;
     // Save for use below.
     $this->ID = 0;
     // Delete this ID now (force empty ID).
     $this->wp = NULL;
     $this->cache = array();
     $this->ip = '';
     $this->email = '';
     $this->username = '';
     $this->nicename = '';
     $this->password = '';
     $this->first_name = '';
     $this->last_name = '';
     $this->full_name = '';
     $this->display_name = '';
     $this->url = '';
     $this->aim = '';
     $this->yim = '';
     $this->jabber = '';
     $this->description = '';
     $this->registration_time = 0;
     $this->activation_key = '';
     $this->status = 0;
     $this->data = array();
     clean_user_cache($ID);
     wp_cache_delete($ID, 'user_meta');
     return TRUE;
     // Default return value.
 }
开发者ID:panvagenas,项目名称:x-related-posts,代码行数:56,代码来源:users.php

示例9: acui_hack_restore_remapped_email_address

function acui_hack_restore_remapped_email_address($user_id, $email)
{
    global $wpdb;
    $wpdb->update($wpdb->users, array('user_email' => $hacked_email), array('ID' => $user_id));
    clean_user_cache($user_id);
}
开发者ID:xalgorithm,项目名称:amcf-wp,代码行数:6,代码来源:email-repeated.php

示例10: wpmu_delete_user

 public static function wpmu_delete_user($id)
 {
     global $wpdb;
     $id = (int) $id;
     $user = new WP_User($id);
     if (!$user->exists()) {
         return false;
     }
     /**
      * Fires before a user is deleted from the network.
      *
      * @since MU
      *
      * @param int $id ID of the user about to be deleted from the network.
      */
     do_action('wpmu_delete_user', $id);
     $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
     foreach ($meta as $mid) {
         delete_metadata_by_mid('user', $mid);
     }
     $wpdb->delete($wpdb->users, array('ID' => $id));
     clean_user_cache($user);
     do_action('deleted_user', $id);
     return true;
 }
开发者ID:geminorum,项目名称:gmember,代码行数:25,代码来源:spam.class.php

示例11: handle_profile_modifications_4bp

 /**
  * Handles Profile modifications for Custom Fields *(created with s2Member)*; integrated with BuddyPress.
  *
  * @package s2Member\Profiles
  * @since 3.5
  *
  * @attaches-to ``add_action('xprofile_updated_profile');``
  */
 public static function handle_profile_modifications_4bp()
 {
     global $current_user;
     // We'll need to update this global object.
     $user =& $current_user;
     // Shorter reference to the ``$current_user`` object.
     do_action('ws_plugin__s2member_before_handle_profile_modifications_4bp', get_defined_vars());
     if (!empty($_POST['ws_plugin__s2member_profile_4bp_save']) && is_user_logged_in() && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         if (($nonce = $_POST['ws_plugin__s2member_profile_4bp_save']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-profile-4bp-save')) {
             $GLOBALS['ws_plugin__s2member_profile_4bp_saved'] = TRUE;
             // Global flag as having been saved/updated successfully.
             $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST));
             // Clean ``$_POST`` vars.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                 if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level('auto-detection', 'profile')) {
                     $fields = array();
                     // Initialize the array of fields.
                     $_existing_fields = get_user_option('s2member_custom_fields', $user_id);
                     foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                         $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                         $field_id_class = preg_replace('/_/', '-', $field_var);
                         if (!in_array($field['id'], $fields_applicable) || strpos($field['editable'], 'no') === 0) {
                             if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                 $fields[$field_var] = $_existing_fields[$field_var];
                             } else {
                                 unset($fields[$field_var]);
                             }
                         } else {
                             if ($field['required'] === 'yes' && (!isset($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) || !is_array($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) && !is_string($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) || is_array($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) && empty($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) || is_string($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) && !strlen($_p['ws_plugin__s2member_profile_4bp_' . $field_var])) || isset($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) && c_ws_plugin__s2member_custom_reg_fields::validation_errors(array($field_var => $_p['ws_plugin__s2member_profile_4bp_' . $field_var]), array($field))) {
                                 if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                     $fields[$field_var] = $_existing_fields[$field_var];
                                 } else {
                                     unset($fields[$field_var]);
                                 }
                             } else {
                                 if (isset($_p['ws_plugin__s2member_profile_4bp_' . $field_var])) {
                                     if ((is_array($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) && !empty($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) || is_string($_p['ws_plugin__s2member_profile_4bp_' . $field_var]) && strlen($_p['ws_plugin__s2member_profile_4bp_' . $field_var])) && !c_ws_plugin__s2member_custom_reg_fields::validation_errors(array($field_var => $_p['ws_plugin__s2member_profile_4bp_' . $field_var]), array($field))) {
                                         $fields[$field_var] = $_p['ws_plugin__s2member_profile_4bp_' . $field_var];
                                     } else {
                                         unset($fields[$field_var]);
                                     }
                                 } else {
                                     unset($fields[$field_var]);
                                 }
                             }
                         }
                     }
                     if (!empty($fields)) {
                         update_user_option($user_id, 's2member_custom_fields', $fields);
                     } else {
                         // Else delete their Custom Fields?
                         delete_user_option($user_id, 's2member_custom_fields');
                     }
                 }
             }
             foreach (array_keys(get_defined_vars()) as $__v) {
                 $__refs[$__v] =& ${$__v};
             }
             do_action('ws_plugin__s2member_during_handle_profile_modifications_4bp', get_defined_vars());
             unset($__refs, $__v);
             clean_user_cache($user_id);
             wp_cache_delete($user_id, 'user_meta');
             $user = new WP_User($user_id);
             // Fresh object.
             if (function_exists('setup_userdata')) {
                 setup_userdata();
             }
             $role = c_ws_plugin__s2member_user_access::user_access_role($user);
             $level = c_ws_plugin__s2member_user_access::user_access_role_to_level($role);
             if (!empty($_p['ws_plugin__s2member_profile_4bp_opt_in']) && $role && $level >= 0) {
                 c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $user->user_login, '', $user->user_email, $user->first_name, $user->last_name, $_SERVER['REMOTE_ADDR'], TRUE, TRUE, $user_id);
             } else {
                 if ($role && $level >= 0 && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in']) {
                     c_ws_plugin__s2member_list_servers::process_list_server_removals($role, $level, $user->user_login, '', $user->user_email, $user->first_name, $user->last_name, $_SERVER['REMOTE_ADDR'], TRUE, $user_id);
                 }
             }
         }
     }
     do_action('ws_plugin__s2member_after_handle_profile_modifications_4bp', get_defined_vars());
 }
开发者ID:adnandot,项目名称:intenseburn,代码行数:88,代码来源:profile-mods-4bp-in.inc.php

示例12: wp_delete_user

/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since 2.0.0
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
开发者ID:radman,项目名称:noobyo-blog,代码行数:55,代码来源:user.php

示例13: wp_edit_username

function wp_edit_username()
{
    global $wpdb, $user_ID;
    $new_username = trim($_POST['new_username']);
    $old_username = trim($_POST['old_username']);
    if ($new_username && $new_username != $old_username) {
        if (!validate_username($new_username)) {
            wp_die("<strong>错误</strong>:用户名只能包含字母、数字、空格、下划线、连字符(-)、点号(.)和 @ 符号。 [ <a href='javascript:onclick=history.go(-1)'>返回</a> ]");
        } elseif (username_exists($new_username)) {
            wp_die(__('<strong>ERROR</strong>: This username is already registered, please choose another one.') . " [ <a href='javascript:onclick=history.go(-1)'>返回</a> ]");
        } else {
            $userid = trim($_POST['user_id']);
            clean_user_cache($userid);
            $wpdb->update($wpdb->users, array('user_login' => $new_username, 'user_nicename' => $new_username, 'user_status' => 3), array('ID' => $userid));
            if ($user_ID == $userid) {
                wp_set_auth_cookie($user_ID, true, false);
            }
            // 更新缓存
        }
    }
}
开发者ID:liangwei1988,项目名称:wordpress,代码行数:21,代码来源:connect.php

示例14: process_list_server_removals_against_current_user

 /**
  * Process list server removals against current user.
  *
  * See {@link process_list_server_removals()} for further details.
  *
  * @since 141004
  * @package s2Member\List_Servers
  *
  * @param bool $opt_out Defaults to `FALSE`; must be set to `TRUE`.
  * @param bool $clean_user_cache Defaults to `TRUE`; i.e., we start from a fresh copy of the current user.
  *
  * @return bool True if at least one list server removal is processed successfully.
  */
 public static function process_list_server_removals_against_current_user($opt_out = FALSE, $clean_user_cache = TRUE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_process_list_server_removals_against_current_user', get_defined_vars());
     unset($__refs, $__v);
     // Allows vars to be modified by reference.
     if ($clean_user_cache) {
         clean_user_cache(get_current_user_id());
         wp_cache_delete(get_current_user_id(), 'user_meta');
         $user = new WP_User(get_current_user_id());
     } else {
         $user = wp_get_current_user();
     }
     return self::process_list_server_removals($role = c_ws_plugin__s2member_user_access::user_access_role($user), $level = c_ws_plugin__s2member_user_access::user_access_level($user), $login = $user->user_login, $pass = $user->user_pass, $email = $user->user_email, $fname = $user->first_name, $lname = $user->last_name, $ip = @$_SERVER['REMOTE_ADDR'], $opt_out = $opt_out, $user_id = $user->ID);
 }
开发者ID:adnandot,项目名称:intenseburn,代码行数:30,代码来源:list-servers.inc.php

示例15: maybe_fix_user_nicename

 function maybe_fix_user_nicename($user_id, $old_user_data = null)
 {
     global $wpdb;
     $user = new WP_User($user_id);
     $user_login = $user->user_login;
     $user_nicename = $user->user_nicename;
     if ($user_nicename != $user_login) {
         return;
     }
     //nothing to fix
     $user_nicename = sanitize_user($user->display_name, true);
     //base the slug/nicename on display name
     $user_nicename = preg_replace('|[ _@]|i', '', $user_nicename);
     $user_nicename = preg_replace('|[^a-z\\-]|i', '', strtolower($user_nicename));
     $user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_nicename = %s OR user_login = %s LIMIT 1", $user_nicename, $user_nicename));
     if ($user_nicename_check) {
         $suffix = 2;
         while ($user_nicename_check) {
             $alt_user_nicename = $user_nicename . "-{$suffix}";
             $user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_nicename = %s OR user_login = %s LIMIT 1", $alt_user_nicename, $alt_user_nicename));
             $suffix++;
         }
         $user_nicename = $alt_user_nicename;
     }
     //update the user_nicename
     $compacted = compact('user_nicename');
     $data = wp_unslash($compacted);
     $ID = (int) $user_id;
     $wpdb->update($wpdb->users, $data, compact('ID'));
     clean_user_cache($user_id);
 }
开发者ID:jonpetersen,项目名称:PHTC,代码行数:31,代码来源:class-signature-admin.php


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