bp_core_boot_spammer( WP_User|WP_Error $user )

Prevent spammers from logging in.

Description

When a user logs in, check if they have been marked as a spammer. If yes then simply redirect them to the home page and stop them from logging in.

Parameters

$user

(WP_User|WP_Error) (Required) Either the WP_User object or the WP_Error object, as passed to the 'authenticate' filter.

Return

(WP_User|WP_Error) If the user is not a spammer, return the WP_User object. Otherwise a new WP_Error object.

Source

File: bp-members/bp-members-functions.php

function bp_core_boot_spammer( $user ) {

	// Check to see if the $user has already failed logging in, if so return $user as-is.
	if ( is_wp_error( $user ) || empty( $user ) ) {
		return $user;
	}

	// The user exists; now do a check to see if the user is a spammer
	// if the user is a spammer, stop them in their tracks!
	if ( is_a( $user, 'WP_User' ) && ( ( is_multisite() && (int) $user->spam ) || 1 == $user->user_status ) ) {
		return new WP_Error( 'invalid_username', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.', 'buddyboss' ) );
	}

	// User is good to go!
	return $user;
}

Changelog

Changelog
Version Description
BuddyPress 1.1.2 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.