wp_get_current_commenter

Get current commenter's name, email, and URL.

Description

(array) wp_get_current_commenter(); 

Expects cookies content to already be sanitized. User of this function might wish to recheck the returned array for validity.

Returns (array)

Comment author, email, url respectively.


Usage

  1. if ( !function_exists( 'wp_get_current_commenter' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_get_current_commenter(); 
  7.  

Defined (1)

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

/wp-includes/comment.php  
  1. function wp_get_current_commenter() { 
  2. // Cookies should already be sanitized. 
  3.  
  4. $comment_author = ''; 
  5. if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) 
  6. $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; 
  7.  
  8. $comment_author_email = ''; 
  9. if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) 
  10. $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; 
  11.  
  12. $comment_author_url = ''; 
  13. if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) 
  14. $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; 
  15.  
  16. /** 
  17. * Filters the current commenter's name, email, and URL. 
  18. * @since 3.1.0 
  19. * @param array $comment_author_data { 
  20. * An array of current commenter variables. 
  21. * @type string $comment_author The name of the author of the comment. Default empty. 
  22. * @type string $comment_author_email The email address of the `$comment_author`. Default empty. 
  23. * @type string $comment_author_url The URL address of the `$comment_author`. Default empty. 
  24. * } 
  25. */