Skip to:
Content

BuddyPress.org

Changeset 9699


Ignore:
Timestamp:
04/06/2015 12:15:20 PM (11 years ago)
Author:
boonebgorges
Message:

Introduce more specific filter names in BP_Core_User::get_specific_users().

Previously, the same filter name was used for both the 'paged' and the 'total'
SQL strings, making the filter difficult to use.

Props tw2113.
Fixes #6352.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-core-user.php

    r9696 r9699  
    548548                $status_sql = bp_core_get_status_sql();
    549549
     550                /**
     551                 * Filter the SQL string used for querying specific user count.
     552                 *
     553                 * This same filter name is used for the paged user SQL, and so should be avoided.
     554                 * Use 'bp_core_user_get_specific_users_count_sql' instead.
     555                 *
     556                 * @deprecated BuddyPress (2.3.0)
     557                 *
     558                 * @param string $sql SQL string.
     559                 */
    550560                $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" );
     561
     562                /**
     563                 * Filter the SQL string used for querying specific user count results.
     564                 *
     565                 * Use this instead of the deprecated 'bp_core_get_specific_users_count_sql'.
     566                 *
     567                 * @since BuddyPress (2.3.0)
     568                 *
     569                 * @param string   $sql             SQL string.
     570                 * @param array    $user_ids        Array of IDs of specific users to fetch.
     571                 * @param int|null $limit           Max number of records to return. Null for no limit.
     572                 * @param int      $page            The page we're on for pagination.
     573                 * @param bool     $populate_extras Whether to populate extra user fields.
     574                 */
     575                $total_users_sql = apply_filters( 'bp_core_user_get_specific_users_count_sql', $total_users_sql, $user_ids, $limit, $page, $populate_extras );
     576
     577                /**
     578                 * Filter the SQL string used for querying specific user paged results.
     579                 *
     580                 * This same filter name is used for the user count SQL, and so should be avoided.
     581                 * Use 'bp_core_user_get_specific_users_paged_sql' instead.
     582                 *
     583                 * @deprecated BuddyPress (2.3.0)
     584                 *
     585                 * @param string $sql SQL string.
     586                 */
    551587                $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT ID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" );
     588
     589                /**
     590                 * Filter the SQL string used for querying specific user paged results.
     591                 *
     592                 * Use this instead of the deprecated 'bp_core_get_specific_users_count_sql'.
     593                 *
     594                 * @since BuddyPress (2.3.0)
     595                 *
     596                 * @param string   $sql             SQL string.
     597                 * @param array    $user_ids        Array of IDs of specific users to fetch.
     598                 * @param int|null $limit           Max number of records to return. Null for no limit.
     599                 * @param int      $page            The page we're on for pagination.
     600                 * @param bool     $populate_extras Whether to populate extra user fields.
     601                 */
     602                $paged_users_sql = apply_filters( 'bp_core_user_get_specific_users_paged_sql', $paged_users_sql, $user_ids, $limit, $page, $populate_extras );
    552603
    553604                $total_users = $wpdb->get_var( $total_users_sql );
Note: See TracChangeset for help on using the changeset viewer.