wp_authenticate_spam_check

函式
wp_authenticate_spam_check ( $user )
引數
  • (WP_User|WP_Error|null) $user WP_User or WP_Error object from a previous callback. Default null.
    Required:
返回值
  • (WP_User|WP_Error) WP_User on success, WP_Error if the user is considered a spammer.
定義位置
相關方法
wp_authenticate_cookiewp_authenticatewp_authenticate_username_passwordwp_auth_checkwp_authenticate_email_password
引入
3.7.0
棄用
-

wp_authenticate_spam_check: 這個函式用於檢查一個使用者是否是垃圾郵件傳送者。

對於多站點部落格,檢查認證使用者是否被標記為垃圾郵件,或者使用者的主部落格是否被標記為垃圾郵件。

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;
}

常見問題

FAQs
檢視更多 >