[wp-hackers] Comment Plugin

Austin Matzko if.website at gmail.com
Mon Apr 10 20:21:51 GMT 2006

On 4/10/06, Oliver Specht <oliver at webride.org> wrote:
> Hi,
> I'd like to write a plugin for the comment function of wordpress. My
> problem is, that I need the nickname/username of the poster of a
> comment. The specialty is, that the user is not logged in so I need the
> POST data from the comment form.
> How do I get it? I used the get_comment_author() function but it only
> returns "Anonymous"...

If you're trying to get comment data right after it's been posted, why
don't you do something like this:

1. Hook a function into the "comment_post" action, which occurs once a
comment has been entered into the database and passes the comment's id
to the function.
2. Use get_commentdata([the comment's id]) to get the author info
about that comment.

function get_the_comment_author($id) {
$data = get_commentdata($id);
$author = $data['comment_author'];

add_action('comment_post', 'get_the_comment_author');

More information about the wp-hackers mailing list