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


PHP BP_Core_User::get_user_extras方法代码示例

本文整理汇总了PHP中BP_Core_User::get_user_extras方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Core_User::get_user_extras方法的具体用法?PHP BP_Core_User::get_user_extras怎么用?PHP BP_Core_User::get_user_extras使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Core_User的用法示例。


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

示例1: search_users

 /**
  * Find users who match on the value of an xprofile data.
  *
  * @global wpdb $wpdb WordPress database object.
  *
  * @param string $search_terms The terms to search the profile table
  *        value column for.
  * @param integer $limit The limit of results we want.
  * @param integer $page The page we are on for pagination.
  * @param boolean $populate_extras Populate extra user fields?
  * @return array Associative array.
  */
 public static function search_users($search_terms, $limit = null, $page = 1, $populate_extras = true)
 {
     global $wpdb;
     $bp = buddypress();
     $user_ids = array();
     $pag_sql = $limit && $page ? $wpdb->prepare(" LIMIT %d, %d", intval(($page - 1) * intval($limit)), intval($limit)) : '';
     $search_terms_like = '%' . bp_esc_like($search_terms) . '%';
     $status_sql = bp_core_get_status_sql('u.');
     /**
      * Filters the SQL used to query for searched users count.
      *
      * @since BuddyPress (1.0.0)
      *
      * @param string $value SQL statement for the searched users count query.
      */
     $total_users_sql = apply_filters('bp_core_search_users_count_sql', $wpdb->prepare("SELECT COUNT(DISTINCT u.ID) as id FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", $search_terms_like), $search_terms);
     /**
      * Filters the SQL used to query for searched users.
      *
      * @since BuddyPress (1.0.0)
      *
      * @param string $value SQL statement for the searched users query.
      */
     $paged_users_sql = apply_filters('bp_core_search_users_sql', $wpdb->prepare("SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like), $search_terms, $pag_sql);
     $total_users = $wpdb->get_var($total_users_sql);
     $paged_users = $wpdb->get_results($paged_users_sql);
     /***
      * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
      * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
      */
     foreach ((array) $paged_users as $user) {
         $user_ids[] = $user->id;
     }
     // Add additional data to the returned results
     if ($populate_extras) {
         $paged_users = BP_Core_User::get_user_extras($paged_users, $user_ids);
     }
     return array('users' => $paged_users, 'total' => $total_users);
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:51,代码来源:class-bp-core-user.php

示例2: search_users

 /**
  * Find users who match on the value of an xprofile data.
  *
  * @global object $bp Global BuddyPress settings object
  * @global nxtdb $nxtdb NXTClass database object
  * @param string $search_terms The terms to search the profile table value column for.
  * @param integer $limit The limit of results we want.
  * @param integer $page The page we are on for pagination.
  * @param boolean $populate_extras Populate extra user fields?
  * @return array Associative array
  * @static
  */
 function search_users($search_terms, $limit = null, $page = 1, $populate_extras = true)
 {
     global $bp, $nxtdb;
     $pag_sql = $limit && $page ? $nxtdb->prepare(" LIMIT %d, %d", intval(($page - 1) * intval($limit)), intval($limit)) : '';
     $search_terms = like_escape($nxtdb->escape($search_terms));
     $status_sql = bp_core_get_status_sql('u.');
     $total_users_sql = apply_filters('bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as id FROM {$nxtdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC", $search_terms);
     $paged_users_sql = apply_filters('bp_core_search_users_sql', "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$nxtdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%{$search_terms}%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql);
     $total_users = $nxtdb->get_var($total_users_sql);
     $paged_users = $nxtdb->get_results($paged_users_sql);
     /***
      * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
      * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
      */
     foreach ((array) $paged_users as $user) {
         $user_ids[] = $user->id;
     }
     $user_ids = $nxtdb->escape(join(',', (array) $user_ids));
     // Add additional data to the returned results
     if ($populate_extras) {
         $paged_users = BP_Core_User::get_user_extras($paged_users, $user_ids);
     }
     return array('users' => $paged_users, 'total' => $total_users);
 }
开发者ID:nxtclass,项目名称:NXTClass,代码行数:36,代码来源:bp-core-classes.php


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