bbp_check_for_flood( array $anonymous_data = array(), int $author_id )
Check for flooding
Description Description
Check to make sure that a user is not making too many posts in a short amount of time.
Parameters Parameters
- $anonymous_data
-
(Optional) - if it's an anonymous post. Do not supply if supplying $author_id. Should be sanitized (see bbp_filter_anonymous_post_data()
Default value: array()
- $author_id
-
(Optional) Supply if it's a post by a logged in user. Do not supply if supplying $anonymous_data.
Return Return
(bool) True if there is no flooding, false if there is
Source Source
File: includes/common/functions.php
function bbp_check_for_flood( $anonymous_data = array(), $author_id = 0 ) { // Allow for flood check to be skipped if ( apply_filters( 'bbp_bypass_check_for_flood', false, $anonymous_data, $author_id ) ) { return true; } // Option disabled. No flood checks. $throttle_time = get_option( '_bbp_throttle_time' ); if ( empty( $throttle_time ) || ! bbp_allow_content_throttle() ) { return true; } // User is anonymous, so check a transient based on the IP if ( ! empty( $anonymous_data ) ) { $last_posted = get_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted' ); if ( ! empty( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) ) { return false; } // User is logged in, so check their last posted time } elseif ( ! empty( $author_id ) ) { $author_id = (int) $author_id; $last_posted = bbp_get_user_last_posted( $author_id ); if ( ! empty( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) && ! user_can( $author_id, 'throttle' ) ) { return false; } } else { return false; } return true; }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |