當前位置: 首頁>>代碼示例>>PHP>>正文


PHP update_user_caches函數代碼示例

本文整理匯總了PHP中update_user_caches函數的典型用法代碼示例。如果您正苦於以下問題:PHP update_user_caches函數的具體用法?PHP update_user_caches怎麽用?PHP update_user_caches使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了update_user_caches函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object

 /**
  * @ticket 24635
  */
 public function test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object()
 {
     global $wpdb;
     $u = self::factory()->user->create();
     $raw_userdata = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE ID = %d", $u));
     $user_object = new WP_User($u);
     update_user_caches($user_object);
     $cached = wp_cache_get($u, 'users');
     $this->assertFalse($cached instanceof WP_User);
     $this->assertEquals($raw_userdata, $cached);
 }
開發者ID:boonebgorges,項目名稱:develop.wordpress,代碼行數:14,代碼來源:updateUserCaches.php

示例2: set_current_user

 public function set_current_user()
 {
     if (!is_user_logged_in()) {
         return;
     }
     global $current_user, $user_identity;
     $old = $current_user->display_name;
     $current_user->display_name = $this->get_display_name($current_user->ID, $current_user->display_name);
     $user_identity = $current_user->display_name;
     if ($old != $user_identity) {
         update_user_caches($current_user);
     }
 }
開發者ID:geminorum,項目名稱:gmember,代碼行數:13,代碼來源:profile.class.php

示例3: forge

 public static function forge($user = null, $cache = true)
 {
     global $wpdb;
     empty($user) and $user = get_current_user_id();
     if (!$cache and is_numeric($user)) {
         if (!($user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE ID = %s", $user)))) {
             return false;
         }
         update_user_caches($user);
     }
     if (empty($user)) {
         return false;
     }
     return new static($user);
 }
開發者ID:daidais,項目名稱:morepress,代碼行數:15,代碼來源:User.php

示例4: _fill_single_user

/**
 * Unserialize user metadata, fill $user object, then cache everything.
 *
 * @since 3.0.0
 * @param object $user The User object.
 * @param array $metavalues An array of objects provided by get_user_metavalues()
 */
function _fill_single_user(&$user, &$metavalues)
{
    global $wpdb;
    foreach ($metavalues as $meta) {
        $value = maybe_unserialize($meta->meta_value);
        // Keys used as object vars cannot have dashes.
        $key = str_replace('-', '', $meta->meta_key);
        $user->{$key} = $value;
    }
    $level = $wpdb->prefix . 'user_level';
    if (isset($user->{$level})) {
        $user->user_level = $user->{$level};
    }
    // For backwards compat.
    if (isset($user->first_name)) {
        $user->user_firstname = $user->first_name;
    }
    if (isset($user->last_name)) {
        $user->user_lastname = $user->last_name;
    }
    if (isset($user->description)) {
        $user->user_description = $user->description;
    }
    update_user_caches($user);
}
開發者ID:hacklabr,項目名稱:toquenobrasil,代碼行數:32,代碼來源:user.php

示例5: cache_users

 /**
  * Retrieve info for user lists to prevent multiple queries by get_userdata()
  *
  * @since 3.0.0
  *
  * @param array $user_ids User ID numbers list
  */
 function cache_users($user_ids)
 {
     global $wpdb;
     $clean = _get_non_cached_ids($user_ids, 'users');
     if (empty($clean)) {
         return;
     }
     $list = implode(',', $clean);
     $users = $wpdb->get_results("SELECT * FROM {$wpdb->users} WHERE ID IN ({$list})");
     $ids = array();
     foreach ($users as $user) {
         update_user_caches($user);
         $ids[] = $user->ID;
     }
     update_meta_cache('user', $ids);
 }
開發者ID:cybKIRA,項目名稱:roverlink-updated,代碼行數:23,代碼來源:pluggable.php

示例6: get_data_by

 /**
  * Return only the main user fields
  *
  * @since 3.3.0
  *
  * @param string $field The field to query against: 'id', 'slug', 'email' or 'login'
  * @param string|int $value The field value
  * @return object Raw user object
  */
 static function get_data_by($field, $value)
 {
     global $wpdb;
     if ('id' == $field) {
         // Make sure the value is numeric to avoid casting objects, for example,
         // to int 1.
         if (!is_numeric($value)) {
             return false;
         }
         $value = absint($value);
     } else {
         $value = trim($value);
     }
     if (!$value) {
         return false;
     }
     switch ($field) {
         case 'id':
             $user_id = $value;
             $db_field = 'ID';
             break;
         case 'slug':
             $user_id = wp_cache_get($value, 'userslugs');
             $db_field = 'user_nicename';
             break;
         case 'email':
             $user_id = wp_cache_get($value, 'useremail');
             $db_field = 'user_email';
             break;
         case 'login':
             $value = sanitize_user($value);
             $user_id = wp_cache_get($value, 'userlogins');
             $db_field = 'user_login';
             break;
         default:
             return false;
     }
     if (false !== $user_id) {
         if ($user = wp_cache_get($user_id, 'users')) {
             return $user;
         }
     }
     if (!($user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE {$db_field} = %s", $value)))) {
         return false;
     }
     update_user_caches($user);
     return $user;
 }
開發者ID:staylor,項目名稱:develop.svn.wordpress.org,代碼行數:57,代碼來源:capabilities.php

示例7: cache_users

 /**
  * Retrieve info for user lists to prevent multiple queries by get_userdata()
  *
  * @since 3.0.0
  *
  * @param array $user_ids User ID numbers list
  */
 function cache_users($user_ids)
 {
     global $nxtdb;
     $clean = array();
     foreach ($user_ids as $id) {
         $id = (int) $id;
         if (!nxt_cache_get($id, 'users')) {
             $clean[] = $id;
         }
     }
     if (empty($clean)) {
         return;
     }
     $list = implode(',', $clean);
     $users = $nxtdb->get_results("SELECT * FROM {$nxtdb->users} WHERE ID IN ({$list})");
     $ids = array();
     foreach ($users as $user) {
         update_user_caches($user);
         $ids[] = $user->ID;
     }
     update_meta_cache('user', $ids);
 }
開發者ID:nxtclass,項目名稱:NXTClass,代碼行數:29,代碼來源:pluggable.php

示例8: get_data_by

	/**
	 * Return only the main user fields
	 *
	 * @since 3.3.0
	 *
	 * @param string $field The field to query against: 'id', 'slug', 'email' or 'login'
	 * @param string|int $value The field value
	 * @return object Raw user object
	 */
	static function get_data_by( $field, $value ) {
		global $wpdb;

		if ( 'id' == $field )
			$value = absint( $value );
		else
			$value = trim( $value );

		if ( !$value )
			return false;

		switch ( $field ) {
			case 'id':
				$user_id = $value;
				$db_field = 'ID';
				break;
			case 'slug':
				$user_id = wp_cache_get($value, 'userslugs');
				$db_field = 'user_nicename';
				break;
			case 'email':
				$user_id = wp_cache_get($value, 'useremail');
				$db_field = 'user_email';
				break;
			case 'login':
				$value = sanitize_user( $value );
				$user_id = wp_cache_get($value, 'userlogins');
				$db_field = 'user_login';
				break;
			default:
				return false;
		}

		if ( false !== $user_id ) {
			if ( $user = wp_cache_get( $user_id, 'users' ) )
				return $user;
		}

		if ( !$user = $wpdb->get_row( $wpdb->prepare(
			"SELECT * FROM $wpdb->users WHERE $db_field = %s", $value
		) ) )
			return false;

		update_user_caches( $user );

		return $user;
	}
開發者ID:staylor,項目名稱:develop.svn.wordpress.org,代碼行數:56,代碼來源:capabilities.php

示例9: _fill_single_user

/**
 * Unserialize user metadata, fill $user object, then cache everything.
 *
 * @since 3.0.0
 * @param object $user The User object.
 * @param array $metavalues An array of objects provided by get_user_metavalues()
 */
function _fill_single_user(&$user, &$metavalues)
{
    global $wpdb;
    foreach ($metavalues as $meta) {
        $value = maybe_unserialize($meta->meta_value);
        $user->{$meta->meta_key} = $value;
    }
    $level = $wpdb->prefix . 'user_level';
    if (isset($user->{$level})) {
        $user->user_level = $user->{$level};
    }
    // For backwards compat.
    if (isset($user->first_name)) {
        $user->user_firstname = $user->first_name;
    }
    if (isset($user->last_name)) {
        $user->user_lastname = $user->last_name;
    }
    if (isset($user->description)) {
        $user->user_description = $user->description;
    }
    update_user_caches($user);
}
開發者ID:beaucollins,項目名稱:wp,代碼行數:30,代碼來源:user.php


注:本文中的update_user_caches函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。