bp_is_user_spammer( int $user_id )
Check whether a user has been marked as a spammer.
Description
Parameters
- $user_id
-
(Required) The ID for the user.
Return
(bool) True if spammer, otherwise false.
Source
File: bp-members/bp-members-functions.php
function bp_is_user_spammer( $user_id = 0 ) { // No user to check. if ( empty( $user_id ) ) { return false; } $bp = buddypress(); // Assume user is not spam. $is_spammer = false; // Setup our user. $user = false; // Get locally-cached data if available. switch ( $user_id ) { case bp_loggedin_user_id() : $user = ! empty( $bp->loggedin_user->userdata ) ? $bp->loggedin_user->userdata : false; break; case bp_displayed_user_id() : $user = ! empty( $bp->displayed_user->userdata ) ? $bp->displayed_user->userdata : false; break; case bp_get_member_user_id() : global $members_template; $user = isset( $members_template ) && isset( $members_template->member ) ? $members_template->member : false; break; } // Manually get userdata if still empty. if ( empty( $user ) ) { $user = get_userdata( $user_id ); } // No user found. if ( empty( $user ) ) { $is_spammer = false; // User found. } else { // Check if spam. if ( !empty( $user->spam ) ) { $is_spammer = true; } if ( 1 == $user->user_status ) { $is_spammer = true; } } /** * Filters whether a user is marked as a spammer. * * @since BuddyPress 1.6.0 * * @param bool $is_spammer Whether or not user is marked as spammer. */ return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer ); }
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.