bp_core_check_for_flood( int $user_id )

Check for flooding.

Description

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

Parameters

$user_id

(int) (Required) User id to check for flood.

Return

(bool) True if there is no flooding, false if there is.

Source

File: bp-core/bp-core-moderation.php

function bp_core_check_for_flood( $user_id = 0 ) {

	// Option disabled. No flood checks.
	if ( !$throttle_time = bp_get_option( '_bp_throttle_time' ) ) {
		return true;
	}

	// Bail if no user ID passed.
	if ( empty( $user_id ) ) {
		return false;
	}

	$last_posted = get_user_meta( $user_id, '_bp_last_posted', true );
	if ( isset( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) && !current_user_can( 'throttle' ) ) {
		return false;
	}

	return true;
}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.