本文整理汇总了PHP中WP_User_Query::get方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_User_Query::get方法的具体用法?PHP WP_User_Query::get怎么用?PHP WP_User_Query::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_User_Query
的用法示例。
在下文中一共展示了WP_User_Query::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatResults
/**
*
* @param \WP_User_Query $uQuery
* @return multitype:number multitype:multitype:string Ambigous <false, string>
*/
public function formatResults(\WP_User_Query $uQuery)
{
$userArray = array();
foreach ($uQuery->get_results() as $user) {
$userArray[] = $this->formatUserAsArray($user);
}
return array("page" => $this->getPage($uQuery->get("number"), $uQuery->get("offset")), "pages" => $this->getNumberOfPages($uQuery->total_users, $uQuery->get("number")), "limit" => $uQuery->get("number"), "total" => $uQuery->total_users, "users" => $userArray);
}
示例2:
function test_get_and_set()
{
$users = new WP_User_Query();
$this->assertEquals('', $users->get('fields'));
$this->assertEquals('', @$users->query_vars['fields']);
$users->set('fields', 'all');
$this->assertEquals('all', $users->get('fields'));
$this->assertEquals('all', $users->query_vars['fields']);
$users->set('fields', '');
$this->assertEquals('', $users->get('fields'));
$this->assertEquals('', $users->query_vars['fields']);
$this->assertNull($users->get('does-not-exist'));
}
示例3: hocwp_setup_theme_pre_get_users
function hocwp_setup_theme_pre_get_users(WP_User_Query $query)
{
if (is_admin()) {
if ($GLOBALS['pagenow'] == 'users.php') {
$user = wp_get_current_user();
$exclude = (array) $query->get('exclude');
$exclude[] = $user->ID;
$exclude = array_unique($exclude);
$query->set('exclude', $exclude);
}
}
return $query;
}