bbp_filter_anonymous_post_data( array $args = array() )

Filter anonymous post data


Description Description

We use REMOTE_ADDR here directly. If you are behind a proxy, you should ensure that it is properly set, such as in wp-config.php, for your environment. See https://core.trac.wordpress.org/ticket/9235

Note that bbp_pre_anonymous_filters() is responsible for sanitizing each of the filtered core anonymous values here.

If there are any errors, those are directly added to bbPress:errors


Parameters Parameters

$args

(Optional) If no args are there, then $_POST values are

Default value: array()


Top ↑

Return Return

(bool|array) False on errors, values in an array on success


Top ↑

Source Source

File: includes/common/functions.php

function bbp_filter_anonymous_post_data( $args = array() ) {

	// Parse arguments against default values
	$r = bbp_parse_args( $args, array(
		'bbp_anonymous_name'    => ! empty( $_POST['bbp_anonymous_name']    ) ? $_POST['bbp_anonymous_name']    : false,
		'bbp_anonymous_email'   => ! empty( $_POST['bbp_anonymous_email']   ) ? $_POST['bbp_anonymous_email']   : false,
		'bbp_anonymous_website' => ! empty( $_POST['bbp_anonymous_website'] ) ? $_POST['bbp_anonymous_website'] : false,
	), 'filter_anonymous_post_data' );

	// Strip invalid characters
	$r = bbp_sanitize_anonymous_post_author( $r );

	// Filter name
	$r['bbp_anonymous_name'] = apply_filters( 'bbp_pre_anonymous_post_author_name', $r['bbp_anonymous_name'] );
	if ( empty( $r['bbp_anonymous_name'] ) ) {
		bbp_add_error( 'bbp_anonymous_name',  __( '<strong>ERROR</strong>: Invalid author name.', 'bbpress' ) );
	}

	// Filter email address
	$r['bbp_anonymous_email'] = apply_filters( 'bbp_pre_anonymous_post_author_email', $r['bbp_anonymous_email'] );
	if ( empty( $r['bbp_anonymous_email'] ) ) {
		bbp_add_error( 'bbp_anonymous_email', __( '<strong>ERROR</strong>: Invalid email address.', 'bbpress' ) );
	}

	// Website is optional (can be empty)
	$r['bbp_anonymous_website'] = apply_filters( 'bbp_pre_anonymous_post_author_website', $r['bbp_anonymous_website'] );

	// Filter & return
	return (array) apply_filters( 'bbp_filter_anonymous_post_data', $r, $args );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.