wp_authenticate_spam_check

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

Description

(WP_User|WP_Error) wp_authenticate_spam_check( (WP_User|WP_Error|null) $user ); 

Returns (WP_User|WP_Error)

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

Parameters (1)

0. $user (WP_User|WP_Error|null)
WP_User or WP_Error object from a previous callback. Default null.

Usage

  1. if ( !function_exists( 'wp_authenticate_spam_check' ) ) { 
  2. require_once ABSPATH . WPINC . '/user.php'; 
  3.  
  4. // WP_User or WP_Error object from a previous callback. Default null. 
  5. $user = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_authenticate_spam_check($user); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/user.php  
  1. function wp_authenticate_spam_check( $user ) { 
  2. if ( $user instanceof WP_User && is_multisite() ) { 
  3. /** 
  4. * Filters whether the user has been marked as a spammer. 
  5. * @since 3.7.0 
  6. * @param bool $spammed Whether the user is considered a spammer. 
  7. * @param WP_User $user User to check against. 
  8. */ 
  9. $spammed = apply_filters( 'check_is_user_spammed', is_user_spammy( $user ), $user ); 
  10.  
  11. if ( $spammed ) 
  12. return new WP_Error( 'spammer_account', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.' ) ); 
  13. return $user;