On this page
wp_get_current_commenter(): array
Gets current commenter’s name, email, and URL.
Description
Expects cookies content to already be sanitized. User of this function might wish to recheck the returned array for validity.
See also
- sanitize_comment_cookies() : Use to sanitize cookies
Return
array An array of current commenter variables.
comment_authorstringThe name of the current commenter, or an empty string.comment_author_emailstringThe email address of the current commenter, or an empty string.comment_author_urlstringThe URL address of the current commenter, or an empty string.
Source
File: wp-includes/comment.php. View all references
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' ) );
}
Hooks
- apply_filters( 'wp_get_current_commenter',
array $comment_author_data ) -
Filters the current commenter’s name, email, and URL.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| Walker_Comment::filter_comment_text() wp-includes/class-walker-comment.php | Filters the comment text. |
| wp_get_unapproved_comment_author_email() wp-includes/comment.php | Gets unapproved comment author’s email. |
| Walker_Comment::comment() wp-includes/class-walker-comment.php | Outputs a single comment. |
| Walker_Comment::html5_comment() wp-includes/class-walker-comment.php | Outputs a comment in the HTML5 format. |
| comment_form() wp-includes/comment-template.php | Outputs a complete commenting form for use within a template. |
| comments_template() wp-includes/comment-template.php | Loads the comment template specified in $file. |
Changelog
| Version | Description |
|---|---|
| 2.0.4 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_current_commenter