Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#14878 closed enhancement (fixed)

wp_get_current_commenter filter

Reported by: louyx's profile louyx Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: Comments Keywords:
Focuses: Cc:


while i was doing something around with the comment system, i've noticed that there's no way to change the comment author fields without touching the WP original code.

the problem is with the wp_get_current_commenter function, there's no action or filter that can be hooked!

the best solution i'm thinking about is adding a hook into the wp_get_current_commenter function, so it'd become something like:

 * 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'));


just applying a filter to the return value, that's all.

Change History (3)

#1 @nacin
14 years ago

  • Type changed from task (blessed) to enhancement

This isn't a blessed task.

#2 @scribu
14 years ago

  • Milestone changed from Awaiting Review to 3.1

I see no harm in adding it.

#3 @scribu
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [15623]) Apply filter to wp_get_current_commenter(). Fixes #14878

Note: See TracTickets for help on using tickets.