Skip to:
Content

bbPress.org

Changeset 3910


Ignore:
Timestamp:
05/21/2012 07:50:04 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Use get_users() in bbp_get_total_users() to avoid a direct database query. See #1826. Props tott.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-user-functions.php

    r3900 r3910  
    10541054 *
    10551055 * @since bbPress (r2769)
    1056  *
    10571056 * @uses wp_cache_get() Check if query is in cache
    1058  * @uses wpdb::get_var() To execute our query and get the var back
     1057 * @uses get_users() To execute our query and get the var back
    10591058 * @uses wp_cache_set() Set the query in the cache
    10601059 * @uses apply_filters() Calls 'bbp_get_total_users' with number of users
     
    10621061 */
    10631062function bbp_get_total_users() {
    1064     global $wpdb;
    10651063
    10661064    $bbp_total_users = wp_cache_get( 'bbp_total_users', 'bbpress' );
     
    10681066        return $bbp_total_users;
    10691067
    1070     $bbp_total_users = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} USE INDEX (PRIMARY);" );
     1068    $bbp_total_users = count( get_users() );
    10711069
    10721070    wp_cache_set( 'bbp_total_users', $bbp_total_users, 'bbpress' );
    10731071
    1074     return apply_filters( 'bbp_get_total_users', (int) $bbp_total_users );
     1072    return (int) apply_filters( 'bbp_get_total_users', (int) $bbp_total_users );
    10751073}
    10761074
Note: See TracChangeset for help on using the changeset viewer.