本文整理汇总了PHP中WP_User_Query类的典型用法代码示例。如果您正苦于以下问题:PHP WP_User_Query类的具体用法?PHP WP_User_Query怎么用?PHP WP_User_Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_User_Query类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: kbs_get_users_by_role
/**
* Retrieve users by role.
*
* @since 1.0
* @param str $role Name of the role to retrieve.
* @return mixed
*/
function kbs_get_users_by_role($role = array('support_agent', 'support_manager'))
{
global $wpdb;
$user_query = new WP_User_Query(array('orderby' => 'display_name', 'role__in' => $role));
$users = $user_query->get_results();
return $users;
}
开发者ID:KB-Support,项目名称:kb-support,代码行数:14,代码来源:user-functions.php
示例2: mdjm_client_count
/**
* Returns a count of clients.
*
* @since 1.4
* @param bool $inactive True to include inactive clients, false to ignore.
* @return int Client count.
*/
function mdjm_client_count($inactive = true)
{
$roles = array('client');
if ($inactive) {
$roles[] = 'inactive_client';
}
$args = array('role__in' => $roles, 'count_total' => true);
$clients = new WP_User_Query($args);
return $clients->get_total();
}
开发者ID:mdjm,项目名称:mobile-dj-manager,代码行数:17,代码来源:client-functions.php
示例3: get_clients
function get_clients()
{
$users = array();
$roles = array('administrator', 'author', 'editor', 'contributor');
foreach ($roles as $role) {
$users_query = new WP_User_Query(array('fields' => 'all_with_meta', 'role' => $role, 'orderby' => 'display_name'));
$results = $users_query->get_results();
if ($results) {
$users = array_merge($users, $results);
}
}
return $users;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:13,代码来源:ourteam_widget.php
示例4: upgrade_store_meta_23
/**
* Upgrade store meta for sellers
* and replace old address meta with new address meta
*
* @since 2.3
*
* @return void
*/
function upgrade_store_meta_23()
{
$query = new WP_User_Query(array('role' => 'seller'));
$sellers = $query->get_results();
$default_settings = array('store_name' => '', 'location' => '', 'find_address' => '', 'banner' => '', 'phone' => '', 'show_email' => '', 'gravatar' => '', 'payment' => array(), 'social' => array());
foreach ($sellers as $seller) {
$current_settings = dokan_get_store_info($seller->ID);
$current_settings = wp_parse_args($current_settings, $default_settings);
$old_address = $current_settings['address'];
$new_address = array('street_1' => $old_address, 'street_2' => '', 'city' => '', 'zip' => '', 'country' => '', 'state' => '');
$current_settings['address'] = $new_address;
update_user_meta($seller->ID, 'dokan_profile_settings', $current_settings);
}
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:22,代码来源:dokan-upgrade-2.3.php
示例5: maybe_get_leads_count
private static function maybe_get_leads_count()
{
if (!self::$_model['is_single']) {
$users = new WP_User_Query(self::$_model['user_args']);
self::$_model['count'] = intval($users->get_total());
}
}
开发者ID:amankatoch,项目名称:wp-plugin,代码行数:7,代码来源:class-displet-rets-idx-lead-manager-page-model.php
示例6: prepare_items
function prepare_items()
{
global $role, $usersearch;
$usersearch = isset($_REQUEST['s']) ? trim($_REQUEST['s']) : '';
$role = isset($_REQUEST['role']) ? $_REQUEST['role'] : '';
$per_page = $this->is_site_users ? 'site_users_network_per_page' : 'users_per_page';
$users_per_page = $this->get_items_per_page($per_page);
$paged = $this->get_pagenum();
$args = array('number' => $users_per_page, 'offset' => ($paged - 1) * $users_per_page, 'role' => $role, 'search' => $usersearch, 'fields' => 'all_with_meta');
if ('' !== $args['search']) {
$args['search'] = '*' . $args['search'] . '*';
}
if ($this->is_site_users) {
$args['blog_id'] = $this->site_id;
}
if (isset($_REQUEST['orderby'])) {
$args['orderby'] = $_REQUEST['orderby'];
}
if (isset($_REQUEST['order'])) {
$args['order'] = $_REQUEST['order'];
}
// Query the user IDs for this page
$wp_user_search = new WP_User_Query($args);
$this->items = $wp_user_search->get_results();
$this->set_pagination_args(array('total_items' => $wp_user_search->get_total(), 'per_page' => $users_per_page));
}
开发者ID:rkglug,项目名称:WordPress,代码行数:26,代码来源:class-wp-users-list-table.php
示例7: html
function html($sp)
{
$list = SPNL()->validate->int($_GET['listID']);
if ($list > 0) {
$role_to_sync = get_post_meta($list, 'sync_role', true);
SendPress_Data::drop_active_subscribers_for_sync($list);
if ($role_to_sync == 'meta') {
$meta_key = get_post_meta($list, 'meta-key', true);
$meta_value = get_post_meta($list, 'meta-value', true);
$meta_compare = get_post_meta($list, 'meta-compare', true);
// WP_User_Query arguments
$args = array('meta_query' => array(array('key' => $meta_key, 'value' => $meta_value, 'compare' => $meta_compare)));
$user_query = new WP_User_Query($args);
$blogusers = $user_query->get_total();
} else {
$result = count_users();
foreach ($result['avail_roles'] as $role => $count) {
if ($role == $role_to_sync) {
$blogusers = $count;
}
}
}
}
//$blogusers = get_users( 'role=' . $role );
//echo count($blogusers);
?>
<div id="taskbar" class="lists-dashboard rounded group">
</div>
<input type="hidden" id="post_ID" name="post_ID" value="<?php
echo $list;
?>
" />
<div class='well' id="sync-wordpress-roles">
<h2><strong><?php
_e('Syncing ', 'sendpress');
?>
<?php
echo ucwords($role);
?>
<?php
_e(' Role to List', 'sendpress');
?>
<?php
echo get_the_title($list);
?>
</strong></h2>
<br>
<div class="progress progress-striped active">
<div class="progress-bar sp-queueit" style="width: 0%;"></div>
</div>
<span id="queue-total">0</span> of <span id="list-total"><?php
echo $blogusers;
?>
</span>
</div>
<?php
}
开发者ID:richardsweeney,项目名称:sendpress,代码行数:60,代码来源:class-sendpress-view-subscribers-sync.php
示例8: get_items
/**
* Get all users
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items($request)
{
$prepared_args = array();
$prepared_args['order'] = $request['order'];
$prepared_args['number'] = $request['per_page'];
$prepared_args['offset'] = ($request['page'] - 1) * $prepared_args['number'];
$orderby_possibles = array('id' => 'ID', 'name' => 'display_name', 'registered_date' => 'registered');
$prepared_args['orderby'] = $orderby_possibles[$request['orderby']];
$prepared_args['search'] = $request['search'];
if (!current_user_can('list_users')) {
$prepared_args['has_published_posts'] = true;
// Only display a public subset of information
$request['context'] = 'embed';
}
if ('' !== $prepared_args['search']) {
$prepared_args['search'] = '*' . $prepared_args['search'] . '*';
}
/**
* Filter arguments, before passing to WP_User_Query, when querying users via the REST API.
*
* @see https://codex.wordpress.org/Class_Reference/WP_User_Query
*
* @param array $prepared_args Array of arguments for WP_User_Query.
* @param WP_REST_Request $request The current request.
*/
$prepared_args = apply_filters('rest_user_query', $prepared_args, $request);
$query = new WP_User_Query($prepared_args);
if (is_wp_error($query)) {
return $query;
}
$users = array();
foreach ($query->results as $user) {
$data = $this->prepare_item_for_response($user, $request);
$users[] = $this->prepare_response_for_collection($data);
}
$response = rest_ensure_response($users);
unset($prepared_args['number']);
unset($prepared_args['offset']);
$prepared_args['fields'] = 'ID';
$count_query = new WP_User_Query($prepared_args);
$total_users = $count_query->get_total();
$response->header('X-WP-Total', (int) $total_users);
$max_pages = ceil($total_users / $request['per_page']);
$response->header('X-WP-TotalPages', (int) $max_pages);
$base = add_query_arg($request->get_query_params(), rest_url('/wp/v2/users'));
if ($request['page'] > 1) {
$prev_page = $request['page'] - 1;
if ($prev_page > $max_pages) {
$prev_page = $max_pages;
}
$prev_link = add_query_arg('page', $prev_page, $base);
$response->link_header('prev', $prev_link);
}
if ($max_pages > $request['page']) {
$next_page = $request['page'] + 1;
$next_link = add_query_arg('page', $next_page, $base);
$response->link_header('next', $next_link);
}
return $response;
}
开发者ID:crazyyy,项目名称:octagram,代码行数:66,代码来源:class-wp-rest-users-controller.php
示例9: render
/**
* Rendering the shortcode this class is responsible for.
*
* @return string $content
*/
public function render()
{
$all_users = $this->user_query->get_results();
// if the user has specified more users add them as well.
if (!empty($this->include)) {
$included_users_query = new WP_User_Query(array('include' => $this->include));
$included_users = $included_users_query->get_results();
if (!empty($included_users)) {
$merged_users = array_merge($all_users, $included_users);
$all_users = $this->users_unique($merged_users);
$all_users = $this->users_sort($all_users);
}
}
// exclude the users not wanted
if (!empty($this->exclude)) {
$all_users = $this->exclude_users($all_users, $this->exclude);
}
if (!count($all_users) > 0) {
return '';
}
$users_output = '';
foreach ($all_users as $user) {
$user_display_name = $this->get_user_public_name($user);
/**
* Sensei teachers shortcode list item filter
*
* @since 1.9.0
*
* @param string $teacher_li the html for the teacher li
* @param WP_User $user
*/
$users_output .= apply_filters('sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="' . get_author_posts_url($user->ID) . '">' . $user_display_name . '<a/></li>', $user);
}
return '<ul class="sensei-teachers">' . $users_output . '</ul>';
}
开发者ID:pra85,项目名称:sensei,代码行数:40,代码来源:class-sensei-shortcode-teachers.php
示例10: get_users
/**
* Ajax callback function to search users that is used on exclude setting page
*
* @uses WP_User_Query WordPress User Query class.
* @return void
*/
public static function get_users()
{
if (!defined('DOING_AJAX') || !current_user_can(WP_Stream_Admin::SETTINGS_CAP)) {
return;
}
check_ajax_referer('stream_get_users', 'nonce');
$response = (object) array('status' => false, 'message' => esc_html__('There was an error in the request', 'stream'));
$search = isset($_POST['find']) ? wp_unslash(trim($_POST['find'])) : '';
$request = (object) array('find' => $search);
add_filter('user_search_columns', array(__CLASS__, 'add_display_name_search_columns'), 10, 3);
$users = new WP_User_Query(array('search' => "*{$request->find}*", 'search_columns' => array('user_login', 'user_nicename', 'user_email', 'user_url'), 'orderby' => 'display_name', 'number' => WP_Stream_Admin::PRELOAD_AUTHORS_MAX));
remove_filter('user_search_columns', array(__CLASS__, 'add_display_name_search_columns'), 10);
if (0 === $users->get_total()) {
wp_send_json_error($response);
}
$response->status = true;
$response->message = '';
$response->users = array();
require_once WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
foreach ($users->results as $key => $user) {
$author = new WP_Stream_Author($user->ID);
$args = array('id' => $author->ID, 'text' => $author->display_name);
$args['tooltip'] = esc_attr(sprintf(__("ID: %d\nUser: %s\nEmail: %s\nRole: %s", 'stream'), $author->id, $author->user_login, $author->user_email, ucwords($author->get_role())));
$args['icon'] = $author->get_avatar_src(32);
$response->users[] = $args;
}
if (empty($search) || preg_match('/wp|cli|system|unknown/i', $search)) {
$author = new WP_Stream_Author(0);
$response->users[] = array('id' => $author->id, 'text' => $author->get_display_name(), 'icon' => $author->get_avatar_src(32), 'tooltip' => esc_html__('Actions performed by the system when a user is not logged in (e.g. auto site upgrader, or invoking WP-CLI without --user)', 'stream'));
}
wp_send_json_success($response);
}
开发者ID:xwp,项目名称:stream-legacy,代码行数:38,代码来源:settings.php
示例11: memberful_private_user_feed_init
function memberful_private_user_feed_init()
{
// In case this is not available, just don't carry on with the logic, it should always be here.
if (!isset($_SERVER['REQUEST_URI'])) {
return;
}
// This is not a case we can verify, so we'll skip
if (strpos($_SERVER['REQUEST_URI'], memberful_private_user_feed_get_url_identifier()) === false) {
return;
}
// Extract the token from the URL
$feedUserToken = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], memberful_private_user_feed_get_url_identifier()) + strlen(memberful_private_user_feed_get_url_identifier()));
$requiredPlan = memberful_private_user_feed_settings_get_required_plan();
// We want to allow the private user feed only if the admin has configured it.
if ($requiredPlan == false) {
return;
}
// The only reliable way to make sure it works on all WP versions
// We'll take "all" users with the token match.
$user_query = new WP_User_Query(array('meta_key' => 'memberful_private_user_feed_token', 'meta_value' => $feedUserToken));
// Get the results from the query
$users = $user_query->get_results();
// We have no results.
if (empty($users)) {
return;
}
// In case somebody actually maps this with their plugin with a hook, we still need to get the first one.
$user = array_shift($users);
if (!is_subscribed_to_memberful_plan($requiredPlan, $user->ID)) {
return;
}
// Everything is in order, we'll deliver the feed.
memberful_private_user_feed_deliver();
}
开发者ID:andrewkhunn,项目名称:lancero,代码行数:34,代码来源:private_user_feed.php
示例12: delete
/**
* Delete User Role and all User's in role if requested
*
* @param boolean $delete_users
*
* @return boolean
*
* @access public
*/
public function delete($delete_users = false)
{
$role = new WP_Roles();
if ($this->getId() !== 'administrator') {
if ($delete_users) {
if (current_user_can('delete_users')) {
//delete users first
$users = new WP_User_Query(array('number' => '', 'blog_id' => get_current_blog_id(), 'role' => $this->getId()));
foreach ($users->get_results() as $user) {
//user can not delete himself
if ($user instanceof WP_User && $user->ID != get_current_user_id()) {
wp_delete_user($user->ID);
}
}
$role->remove_role($this->getId());
$status = true;
} else {
$status = false;
}
} else {
$role->remove_role($this->getId());
$status = true;
}
} else {
$status = false;
}
return $status;
}
开发者ID:subhadip-sahoo,项目名称:wp-project1,代码行数:37,代码来源:role.php
示例13: get_ex_members
function get_ex_members()
{
$ex_synergia_member_args = array('role' => 'ex_synergia_member');
$ex_synergia_member_query = new WP_User_Query($ex_synergia_member_args);
$ex_synergia_members = $ex_synergia_member_query->get_results();
return $ex_synergia_members;
}
开发者ID:synergia,项目名称:mknm-synergia-theme,代码行数:7,代码来源:utils.php
示例14: rcp_count_members
function rcp_count_members($level = '', $status = 'active', $recurring = null, $search = '')
{
global $wpdb;
if ($status == 'free') {
if (!empty($level)) {
$args = array('meta_query' => array(array('key' => 'rcp_subscription_level', 'value' => $level), array('key' => 'rcp_status', 'value' => 'free')));
} else {
$args = array('meta_query' => array(array('key' => 'rcp_status', 'value' => 'free')));
}
} else {
if (!empty($level)) {
$args = array('meta_query' => array(array('key' => 'rcp_subscription_level', 'value' => $level), array('key' => 'rcp_status', 'value' => $status)));
} else {
$args = array('meta_query' => array(array('key' => 'rcp_status', 'value' => $status)));
}
}
if (!empty($recurring)) {
if ($recurring == 1) {
// find non recurring users
$args['meta_query'][] = array('key' => 'rcp_recurring', 'compare' => 'NOT EXISTS');
} else {
// find recurring users
$args['meta_query'][] = array('key' => 'rcp_recurring', 'value' => 'yes');
}
}
if (!empty($search)) {
$args['search'] = sanitize_text_field($search);
}
$args['fields'] = 'ID';
$users = new WP_User_Query($args);
return $users->get_total();
}
开发者ID:bunnywong,项目名称:freshlinker,代码行数:32,代码来源:member-functions.php
示例15: pd_cd_get_customer_users
/**
* Get the customer list.
*
* Taken from WooCommerce code at:
* includes/admin/reports/class-wc-report-customer-list.php:WC_Report_Customer_List->prepare_items()
*
* @since 0.1.0
*
* @return array User list
*/
function pd_cd_get_customer_users()
{
$admin_users = new WP_User_Query(array('role' => 'administrator1', 'fields' => 'ID'));
$manager_users = new WP_User_Query(array('role' => 'shop_manager', 'fields' => 'ID'));
$query = new WP_User_Query(array('exclude' => array_merge($admin_users->get_results(), $manager_users->get_results())));
$customers = $query->get_results();
return $customers;
}
开发者ID:realbig,项目名称:PL_PEACEFULDRAGON_CUSTOMERDATA,代码行数:18,代码来源:pd-customerdata-functions.php
示例16: get_user_by_meta_data
protected function get_user_by_meta_data($meta_key, $meta_value)
{
// Query for users based on the meta data
$user_query = new WP_User_Query(array('meta_key' => $meta_key, 'meta_value' => $meta_value));
// Get the results from the query, returning the first user
$users = $user_query->get_results();
return isset($users[0]) ? $users[0] : 0;
}
开发者ID:httvncoder,项目名称:151722441,代码行数:8,代码来源:class-dln-json-fbusers.php
示例17: prepare_items
/**
*
* @global string $usersearch
* @global string $role
* @global wpdb $wpdb
* @global string $mode
*/
public function prepare_items() {
global $usersearch, $role, $wpdb, $mode;
$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
$paged = $this->get_pagenum();
$args = array(
'number' => $users_per_page,
'offset' => ( $paged-1 ) * $users_per_page,
'search' => $usersearch,
'blog_id' => 0,
'fields' => 'all_with_meta'
);
if ( wp_is_large_network( 'users' ) )
$args['search'] = ltrim( $args['search'], '*' );
if ( $role == 'super' ) {
$logins = implode( "', '", get_super_admins() );
$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
}
/*
* If the network is large and a search is not being performed,
* show only the latest users with no paging in order to avoid
* expensive count queries.
*/
if ( !$usersearch && wp_is_large_network( 'users' ) ) {
if ( !isset($_REQUEST['orderby']) )
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
if ( !isset($_REQUEST['order']) )
$_GET['order'] = $_REQUEST['order'] = 'DESC';
$args['count_total'] = false;
}
if ( isset( $_REQUEST['orderby'] ) )
$args['orderby'] = $_REQUEST['orderby'];
if ( isset( $_REQUEST['order'] ) )
$args['order'] = $_REQUEST['order'];
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
// Query the user IDs for this page
$wp_user_search = new WP_User_Query( $args );
$this->items = $wp_user_search->get_results();
$this->set_pagination_args( array(
'total_items' => $wp_user_search->get_total(),
'per_page' => $users_per_page,
) );
}
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:65,代码来源:class-wp-ms-users-list-table.php
示例18: um_clean_user_basename_filter
function um_clean_user_basename_filter($value, $raw)
{
global $wpdb;
$permalink_base = um_get_option('permalink_base');
$user_query = new WP_User_Query(array('meta_query' => array('relation' => 'AND', array('key' => 'um_user_profile_url_slug_name_' . $raw), array('key' => 'account_status', 'value' => 'awaiting_admin_review', 'compare' => '!='))));
$result = current($user_query->get_results());
$slugname = '';
if (isset($result->data->ID)) {
$slugname = get_user_meta($result->data->ID, 'um_user_profile_url_slug_name_' . $raw, true);
$value = $slugname;
}
$value = apply_filters("um_permalink_base_before_filter", $value);
$raw_value = $value;
switch ($permalink_base) {
case 'name':
if (!empty($value) && strrpos($value, "_") > -1) {
$value = str_replace('_', '. ', $value);
}
if (!empty($value) && strrpos($value, "_") > -1) {
$value = str_replace('_', '-', $value);
}
if (!empty($value) && strrpos($value, ".") > -1 && strrpos($raw_value, "_") <= -1) {
$value = str_replace('.', ' ', $value);
}
$value = apply_filters("um_permalink_base_after_filter_name", $value, $raw_value);
break;
case 'name_dash':
if (!empty($value) && strrpos($value, "-") > -1) {
$value = str_replace('-', ' ', $value);
}
if (!empty($value) && strrpos($value, "_") > -1) {
$value = str_replace('_', '-', $value);
}
// Checks if last name has a dash
if (!empty($value) && strrpos($value, "_") > -1) {
$value = str_replace('_', '-', $value);
}
$value = apply_filters("um_permalink_base_after_filter_name_dash", $value, $raw_value);
break;
case 'name_plus':
if (!empty($value) && strrpos($value, "+") > -1) {
$value = str_replace('+', ' ', $value);
}
if (!empty($value) && strrpos($value, "_") > -1) {
$value = str_replace('_', '+', $value);
}
$value = apply_filters("um_permalink_base_after_filter_name_plus", $value, $raw_value);
break;
default:
// Checks if last name has a dash
if (!empty($value) && strrpos($value, "_") > -1 && substr($value, "_") == 1) {
$value = str_replace('_', '-', $value);
}
$value = apply_filters("um_permalink_base_after_filter", $value, $raw_value);
break;
}
return $value;
}
开发者ID:TeamSubjectMatter,项目名称:juddfoundation,代码行数:58,代码来源:um-filters-user.php
示例19: get_members
/**
* Get users who signed up for a membership.
*
* @param array $args
* @return WP_User_Query
*/
public function get_members($args)
{
global $wpdb;
$user_query = new WP_User_Query();
$user_query->prepare_query($args);
$user_query->query_from .= ' INNER JOIN ' . $this->tbl_members . ' ib_edu_m ON ib_edu_m.user_id = ' . $wpdb->users . '.ID';
$user_query->query();
return $user_query;
}
开发者ID:zaro,项目名称:ibeducator,代码行数:15,代码来源:Memberships.php
示例20: capture_query
function capture_query($args)
{
$args['count_total'] = false;
$uq = new WP_User_Query();
$uq->_p2p_capture = true;
// needed by P2P_URL_Query
$uq->prepare_query($args);
return "SELECT {$uq->query_fields} {$uq->query_from} {$uq->query_where} {$uq->query_orderby} {$uq->query_limit}";
}
开发者ID:vladflip,项目名称:carewp,代码行数:9,代码来源:side-user.php
注:本文中的WP_User_Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论