This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

BBP_Akismet::maybe_spam( array $post_data, string $check = 'check', string $spam = 'spam' )

Ping Akismet service and check for spam/ham response

Description

Parameters

$post_data

(array) (Required)

$check

(string) (Optional) Accepts check|submit

Default value: 'check'

$spam

(string) (Optional) Accepts spam|ham

Default value: 'spam'

Return

(array) Array of post data

Source

File: bp-forums/extend/akismet.php

	private function maybe_spam( $post_data, $check = 'check', $spam = 'spam' ) {
		global $akismet_api_host, $akismet_api_port;

		// Define variables
		$query_string = $path = $response = '';

		// Populate post data
		$post_data['blog']         = get_option( 'home' );
		$post_data['blog_charset'] = get_option( 'blog_charset' );
		$post_data['blog_lang']    = get_locale();
		$post_data['referrer']     = $_SERVER['HTTP_REFERER'];
		$post_data['user_agent']   = $_SERVER['HTTP_USER_AGENT'];

		// Akismet Test Mode
		if ( akismet_test_mode() )
			$post_data['is_test'] = 'true';

		// Loop through _POST args and rekey strings
		foreach ( $_POST as $key => $value )
			if ( is_string( $value ) )
				$post_data['POST_' . $key] = $value;

		// Keys to ignore
		$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );

		// Loop through _SERVER args and remove whitelisted keys
		foreach ( $_SERVER as $key => $value ) {

			// Key should not be ignored
			if ( !in_array( $key, $ignore ) && is_string( $value ) ) {
				$post_data[$key] = $value;

			// Key should be ignored
			} else {
				$post_data[$key] = '';
			}
		}

		// Ready...
		foreach ( $post_data as $key => $data )
			$query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';

		// Aim...
		if ( 'check' === $check ) {
			$path = '/1.1/comment-check';
		} elseif ( 'submit' === $check ) {
			$path = '/1.1/submit-' . $spam;
		}

		// Fire!
		$response = $this->http_post( $query_string, $akismet_api_host, $path, $akismet_api_port );

		// Check the high-speed cam
		if ( !empty( $response[1] ) ) {
			$post_data['bbp_akismet_result'] = $response[1];
		} else {
			$post_data['bbp_akismet_result'] = esc_html__( 'No response', 'buddyboss' );
		}

		// This is ham
		return $post_data;
	}

Changelog

Changelog
Version Description
bbPress (r3277) 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.