本文整理汇总了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;未经允许,请勿转载。 |
请发表评论