bbp_get_current_anonymous_user_data

Get the cookies for current poster (uses WP comment cookies).

Description

(string|array) bbp_get_current_anonymous_user_data( (string) $key = '' ); 

Returns (string|array)

Cookie(s) for current poster

Parameters (1)

0. $key — Optional. (string) => ''
Which value to get? If not given, then an array is returned.

Usage

  1. if ( !function_exists( 'bbp_get_current_anonymous_user_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/functions.php'; 
  3.  
  4. // Optional. Which value to get? If not given, then 
  5. // an array is returned. 
  6. $key = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bbp_get_current_anonymous_user_data($key); 
  10.  

Defined (1)

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

/includes/users/functions.php  
  1. function bbp_get_current_anonymous_user_data( $key = '' ) { 
  2. $cookie_names = array( 
  3. 'name' => 'comment_author',  
  4. 'email' => 'comment_author_email',  
  5. 'url' => 'comment_author_url',  
  6.  
  7. // Here just for the sake of them, use the above ones 
  8. 'comment_author' => 'comment_author',  
  9. 'comment_author_email' => 'comment_author_email',  
  10. 'comment_author_url' => 'comment_author_url',  
  11. ); 
  12.  
  13. sanitize_comment_cookies(); 
  14.  
  15. $bbp_current_poster = wp_get_current_commenter(); 
  16.  
  17. if ( !empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) 
  18. return $bbp_current_poster[$cookie_names[$key]]; 
  19.  
  20. return $bbp_current_poster;