bbp_filter_anonymous_post_data

Filter anonymous post data.

Description

(bool|array) bbp_filter_anonymous_post_data( (string) $args = '' ); 

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

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

Returns (bool|array)

False on errors, values in an array on success

Parameters (1)

0. $args — Optional. (string) => ''
If no args are there, then $_POST values are used.

Usage

  1. if ( !function_exists( 'bbp_filter_anonymous_post_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/functions.php'; 
  3.  
  4. // Optional. If no args are there, then $_POST values are 
  5. // used. 
  6. $args = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bbp_filter_anonymous_post_data($args); 
  10.  

Defined (1)

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

/includes/common/functions.php  
  1. function bbp_filter_anonymous_post_data( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array ( 
  5. 'bbp_anonymous_name' => !empty( $_POST['bbp_anonymous_name'] ) ? $_POST['bbp_anonymous_name'] : false,  
  6. 'bbp_anonymous_email' => !empty( $_POST['bbp_anonymous_email'] ) ? $_POST['bbp_anonymous_email'] : false,  
  7. 'bbp_anonymous_website' => !empty( $_POST['bbp_anonymous_website'] ) ? $_POST['bbp_anonymous_website'] : false,  
  8. ), 'filter_anonymous_post_data' ); 
  9.  
  10. // Filter variables and add errors if necessary 
  11. $r['bbp_anonymous_name'] = apply_filters( 'bbp_pre_anonymous_post_author_name', $r['bbp_anonymous_name'] ); 
  12. if ( empty( $r['bbp_anonymous_name'] ) ) 
  13. bbp_add_error( 'bbp_anonymous_name', __( '<strong>ERROR</strong>: Invalid author name submitted!', bbpress ) ); 
  14.  
  15. $r['bbp_anonymous_email'] = apply_filters( 'bbp_pre_anonymous_post_author_email', $r['bbp_anonymous_email'] ); 
  16. if ( empty( $r['bbp_anonymous_email'] ) ) 
  17. bbp_add_error( 'bbp_anonymous_email', __( '<strong>ERROR</strong>: Invalid email address submitted!', bbpress ) ); 
  18.  
  19. // Website is optional 
  20. $r['bbp_anonymous_website'] = apply_filters( 'bbp_pre_anonymous_post_author_website', $r['bbp_anonymous_website'] ); 
  21.  
  22. // Return false if we have any errors 
  23. $retval = bbp_has_errors() ? false : $r; 
  24.  
  25. // Finally, return sanitized data or false 
  26. return apply_filters( 'bbp_filter_anonymous_post_data', $retval, $r );