wp_authenticate_spam_check() WordPress Function

The wp_authenticate_spam_check() function checks whether a user is a spammer. It does this by checking the user's IP address against the Stop Forum Spam database. If the user is found to be a spammer, their account will be blocked.

wp_authenticate_spam_check( WP_User|WP_Error|null $user ) #

For Multisite blogs, checks if the authenticated user has been marked as a spammer, or if the user’s primary blog has been marked as spam.


Parameters

$user

(WP_User|WP_Error|null)(Required)WP_User or WP_Error object from a previous callback. Default null.


Top ↑

Return

(WP_User|WP_Error) WP_User on success, WP_Error if the user is considered a spammer.


Top ↑

Source

File: wp-includes/user.php

function wp_authenticate_spam_check( $user ) {
	if ( $user instanceof WP_User && is_multisite() ) {
		/**
		 * Filters whether the user has been marked as a spammer.
		 *
		 * @since 3.7.0
		 *
		 * @param bool    $spammed Whether the user is considered a spammer.
		 * @param WP_User $user    User to check against.
		 */
		$spammed = apply_filters( 'check_is_user_spammed', is_user_spammy( $user ), $user );

		if ( $spammed ) {
			return new WP_Error( 'spammer_account', __( '<strong>Error</strong>: Your account has been marked as a spammer.' ) );
		}
	}
	return $user;
}


Top ↑

Changelog

Changelog
VersionDescription
3.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More