making your gravatar work with pingbacks

The following post is only relevant for people using WordPress.

Ok. So, let’s say you read a blog post, and you want to comment on that post on your own blog. So, you write your post and include a link back to the original post. When you publish the post, WordPress sends what’s called a pingback to the other blog, letting it know that you linked to it. This pingback shows up in the comments section so readers reading that article can click on to yours and read your response.

Enter Gravatars. These are avatars that follow you whereever you go online so if you comment on a blog and enter your information, it will automatically retrieve your Gravatar (if the blog has the feature enabled). Beside every comment you leave, your own custom icon is displayed.

Well, I discovered that when a blog sends a pingback to another blog that has Gravatars enabled, a generic placeholder shows up. No good! When my blog sends a pingback, I want my Gravatar to show up, just as if I had left a comment.

Well, if you own a WordPress blog, there’s a very simple way to make sure that your Gravatar appears when your blog sends a pingback. To make YOUR Gravatar appear on the blog you’re pinging, you need to do the following:

  1. open xmlrpc.php
  2. find the following code:

    $comment_post_ID = (int) $post_ID;
    $comment_author = $title;
    $comment_author_url = $pagelinkedfrom;
    $comment_content = $context;
    $comment_type = 'pingback';

  3. under the line $comment_author = $title; insert:

    $comment_author_email = '';

    (obviously replace “” with the eMail address you used to register your Gravatar)

  4. Find the line:

    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
    and after 'comment_author' add:

    (note: don’t forget to separate with a comma and a space!)

  5. upload and replace xmlrpc.php in the root of your blog directory

Gravatars work by referencing the registered eMail address and this additional code posts your eMail address along with the pingback, letting the blog know what account to access the Gravatar from. I have no idea how it all works and I’m surprised this solution works at all, but I’m not going to question a good thing!