[wp-hackers] wp_get_current_commenter

Otto otto at ottodestruct.com
Thu Aug 12 19:37:35 UTC 2010


I didn't even consider looking at the wp_get_current_commenter function.

Why don't you just set those COOKIE globals yourself? That way you can
control what it returns.

-Otto



On Thu, Aug 12, 2010 at 1:25 PM, Louy <louy08 at gmail.com> wrote:
> yea i know :) i'm just thinking... what if the theme needs to edit this
> html, it'd call the wp_get_current_commenter function and use it's own data!
> so i think there should be a better solution... maybe applying the filter to
> the returned value of the function "wp_get_current_commenter()" so it'd be:
>
> /**
>>  * 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'));
>>
>> }
>>
>>  That's the best logical solution don't you think ;)
>
> On Thu, Aug 12, 2010 at 9:17 PM, Otto <otto at ottodestruct.com> wrote:
>
>> On Thu, Aug 12, 2010 at 1:13 PM, Louy <louy08 at gmail.com> wrote:
>> > hmmm, i looked through every available filter, it isn't there!
>> > ...
>> > That's the missing filter... yet any alternatives?
>>
>> Use the comment_form_default_fields filter. You'll have to make the
>> whole field item (label and input and everything), but this will give
>> you control over that part of it.
>>
>> -Otto
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Louy
> http://louyblog.wordpress.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list