bp_core_check_for_flood

Check for flooding.

Description

bp_core_check_for_flood( (int) $user_id = 0 ); 

Check to make sure that a user is not making too many posts in a short amount of time.

Parameters (1)

0. $user_id — Optional. (int)
User id to check for flood.

Usage

  1. if ( !function_exists( 'bp_core_check_for_flood' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-moderation.php'; 
  3.  
  4. // User id to check for flood. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_check_for_flood($user_id); 
  9.  

Defined (1)

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

/bp-core/bp-core-moderation.php  
  1. function bp_core_check_for_flood( $user_id = 0 ) { 
  2.  
  3. // Option disabled. No flood checks. 
  4. if ( !$throttle_time = bp_get_option( '_bp_throttle_time' ) ) { 
  5. return true; 
  6.  
  7. // Bail if no user ID passed. 
  8. if ( empty( $user_id ) ) { 
  9. return false; 
  10.  
  11. $last_posted = get_user_meta( $user_id, '_bp_last_posted', true ); 
  12. if ( isset( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) && !current_user_can( 'throttle' ) ) { 
  13. return false; 
  14.  
  15. return true;