bp_registration_options_remove_moderated_count

Filter our user count to take into account spam members.

Description

(mixed|null|string) bp_registration_options_remove_moderated_count( (number) $count ); 

Returns (mixed|null|string)

Parameters (1)

0. $count (number)
Total active users.

Usage

  1. if ( !function_exists( 'bp_registration_options_remove_moderated_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-registration-options/includes/core.php'; 
  3.  
  4. // Total active users. 
  5. $count = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_registration_options_remove_moderated_count($count); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/core.php  
  1. function bp_registration_options_remove_moderated_count( $count ) { 
  2.  
  3.  
  4. if ( '0' === $pending_count ) { 
  5. return $count; 
  6.  
  7. global $wpdb; 
  8.  
  9. $total_count = get_transient( 'bpro_total_user_count' ); 
  10.  
  11. if ( false === $total_count ) { 
  12.  
  13. $status_sql = 'user_status = 0'; 
  14.  
  15. if ( is_multisite() ) { 
  16. $status_sql = 'spam = 0 AND deleted = 0 AND user_status = 0'; 
  17.  
  18. $total_count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" ); 
  19.  
  20. set_transient( 'bpro_total_user_count', $total_count, HOUR_IN_SECONDS ); 
  21.  
  22. $final_count = ( $total_count - $pending_count ); 
  23.  
  24. return ( $final_count > 0 ) ? $final_count : $count; 
  25.