wp_get_current_commenter

The timeline below displays how wordpress function wp_get_current_commenter has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Gets current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array {
 *     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.
 * }
 */
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'));
}

WordPress Version: 5.4

/**
 * Get current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array {
 *     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.
 * }
 */
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'));
}

WordPress Version: 4.6

/**
 * Get current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array Comment author, email, url respectively.
 */
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 author of the comment. Default empty.
     *     @type string $comment_author_email The email address of the `$comment_author`. Default empty.
     *     @type string $comment_author_url   The URL address of the `$comment_author`. Default empty.
     * }
     */
    return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
}

WordPress Version: 4.4

/**
 * Get current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array Comment author, email, url respectively.
 */
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];
    }
    /**
     * Filter 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 author of the comment. Default empty.
     *     @type string $comment_author_email The email address of the `$comment_author`. Default empty.
     *     @type string $comment_author_url   The URL address of the `$comment_author`. Default empty.
     * }
     */
    return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
}

WordPress Version: 3.8

/**
 * Get current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array Comment author, email, url respectively.
 */
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];
    }
    /**
     * Filter the current commenter's name, email, and URL.
     *
     * @since 3.1.0
     *
     * @param string $comment_author       Comment author's name.
     * @param string $comment_author_email Comment author's email.
     * @param string $comment_author_url   Comment author's URL.
     */
    return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
}

WordPress Version: 3.7

/**
 * Get current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array Comment author, email, url respectively.
 */
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];
    }
    return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
}