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

(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

1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
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.