home contact syndicate

WordPress, My Gravatar and the Mystery Man

Mystery Man - the default Gravatar

Mystery Man - the default Gravatar

I just had a problem with my own gravatar not showing up on my own site for the comments I wrote. First I thought that clearing the browser cache would solve everything. I was wrong. After clearing the cache, deleting cookies and checking my gravatar (http://en.gravatar.com/site/check/), I was really out of (quick) ideas. Then it suddenly hit me: a few days ago I changed a few things in my Blog’s user accounts. I added new accounts with different user rights and merged the old accounts with the new ones.

After having a look at WordPress’s gravatar code (wp-includes/pluggable.php), everything was clear: WordPress actually pulls the user id and gets the email address which is stored in the user account data for this id. This ensures that if a user changes the email address in the user account, it will always pull the new gravatar associated with the new email address. The user id - for registered users - is stored in the comments table for each and every comment.

That said, if you change user accounts and a user id changes, you need to run

UPDATE wp_comments SET user_id = new_user_id WHERE user_id = old_user_id

otherwise you’re going to have a lot comments from the mystery man…

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

2 Responses to “WordPress, My Gravatar and the Mystery Man”

  1. karchesky said :

    Thank you. I “migrated” some comments from an old version of my site to the new one by the expeditive process of posting the comments myself, then editing the commenter info (it was only a handful of comments), and was puzzled as to why my gravatar kept showing instead of my commenters’. So this is why. Again thanks.

  2. Toxane said :

    @karchesky

    Glad it helped you.

    ;-)

Leave a Reply