wp_get_current_commenter

Advertisement

Summery Summery

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

Syntax Syntax

wp_get_current_commenter()

Description Description

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

Return 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 Source

File: wp-includes/comment.php

	 * Translate raw statuses to human-readable formats for the hooks.
	 * This is not a complete list of comment status, it's only the ones
	 * that need to be renamed.
	 */
	$comment_statuses = array(
		0         => 'unapproved',
		'hold'    => 'unapproved', // wp_set_comment_status() uses "hold".
		1         => 'approved',
		'approve' => 'approved',   // wp_set_comment_status() uses "approve".
	);
	if ( isset( $comment_statuses[ $new_status ] ) ) {
		$new_status = $comment_statuses[ $new_status ];
	}
	if ( isset( $comment_statuses[ $old_status ] ) ) {
		$old_status = $comment_statuses[ $old_status ];
	}

	// Call the hooks.
	if ( $new_status != $old_status ) {
		/**
		 * Fires when the comment status is in transition.
		 *
		 * @since 2.7.0
		 *
		 * @param int|string $new_status The new comment status.
		 * @param int|string $old_status The old comment status.
		 * @param WP_Comment $comment    Comment object.
		 */
		do_action( 'transition_comment_status', $new_status, $old_status, $comment );
		/**
		 * Fires when the comment status is in transition from one specific status to another.
		 *
		 * The dynamic portions of the hook name, `$old_status`, and `$new_status`,

Advertisement

Changelog Changelog

Changelog
Version Description
2.0.4 Introduced.

See also See also

Advertisement

Leave a Reply