Title: wp_get_current_commenter
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_get_current_commenter(): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#see-also)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#wp--skip-link--target)

Gets current commenter’s name, email, and URL.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#description)󠁿

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

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#see-also)󠁿

 * [sanitize_comment_cookies()](https://developer.wordpress.org/reference/functions/sanitize_comment_cookies/):
   Use to sanitize cookies

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#return)󠁿

 array An array of current commenter variables.

 * `comment_author` string
 * The name of the current commenter, or an empty string.
 * `comment_author_email` string
 * The email address of the current commenter, or an empty string.
 * `comment_author_url` string
 * The URL address of the current commenter, or an empty string.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#source)󠁿

    ```php
    function wp_get_current_commenter() {
    	// Cookies should already be sanitized.

    	$comment_author = '';
    	if ( isset( $_COOKIE[ 'comment_author_' . COOKIEHASH ] ) ) {
    		$comment_author = $_COOKIE[ 'comment_author_' . COOKIEHASH ];
    	}

    	$comment_author_email = '';
    	if ( isset( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) ) {
    		$comment_author_email = $_COOKIE[ 'comment_author_email_' . COOKIEHASH ];
    	}

    	$comment_author_url = '';
    	if ( isset( $_COOKIE[ 'comment_author_url_' . COOKIEHASH ] ) ) {
    		$comment_author_url = $_COOKIE[ 'comment_author_url_' . COOKIEHASH ];
    	}

    	/**
    	 * Filters the current commenter's name, email, and URL.
    	 *
    	 * @since 3.1.0
    	 *
    	 * @param array $comment_author_data {
    	 *     An array of current commenter variables.
    	 *
    	 *     @type string $comment_author       The name of the current commenter, or an empty string.
    	 *     @type string $comment_author_email The email address of the current commenter, or an empty string.
    	 *     @type string $comment_author_url   The URL address of the current commenter, or an empty string.
    	 * }
    	 */
    	return apply_filters( 'wp_get_current_commenter', compact( 'comment_author', 'comment_author_email', 'comment_author_url' ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment.php#L1989)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment.php#L1989-L2021)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_get_current_commenter’, array $comment_author_data )](https://developer.wordpress.org/reference/hooks/wp_get_current_commenter/)

Filters the current commenter’s name, email, and URL.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#related)󠁿

| Uses | Description | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

| Used by | Description | 
| [Walker_Comment::filter_comment_text()](https://developer.wordpress.org/reference/classes/walker_comment/filter_comment_text/)`wp-includes/class-walker-comment.php` |

Filters the comment text.

  | 
| [wp_get_unapproved_comment_author_email()](https://developer.wordpress.org/reference/functions/wp_get_unapproved_comment_author_email/)`wp-includes/comment.php` |

Gets unapproved comment author’s email.

  | 
| [Walker_Comment::comment()](https://developer.wordpress.org/reference/classes/walker_comment/comment/)`wp-includes/class-walker-comment.php` |

Outputs a single comment.

  | 
| [Walker_Comment::html5_comment()](https://developer.wordpress.org/reference/classes/walker_comment/html5_comment/)`wp-includes/class-walker-comment.php` |

Outputs a comment in the HTML5 format.

  | 
| [comment_form()](https://developer.wordpress.org/reference/functions/comment_form/)`wp-includes/comment-template.php` |

Outputs a complete commenting form for use within a template.

  | 
| [comments_template()](https://developer.wordpress.org/reference/functions/comments_template/)`wp-includes/comment-template.php` |

Loads the comment template specified in $file.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.4](https://developer.wordpress.org/reference/since/2.0.4/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/?output_format=md#comment-content-1622)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_current_commenter/#comment-1622)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_current_commenter%2F%23comment-1622)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_current_commenter%2F%23comment-1622)
 4. **Get current commenter detail**
 5.     ```php
        $current_commenter = wp_get_current_commenter();
        ```
    
 6. Output:
 7.     ```php
        Array
        (
            [comment_author] => John Doe
            [comment_author_email] => johndoe@gmail.com
            [comment_author_url] => http://example.com
        )
        ```
    
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_current_commenter%2F%3Freplytocom%3D1622%23feedback-editor-1622)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_current_commenter%2F)
before being able to contribute a note or feedback.