Missing Gravator profile pic after changing Wordpress username

13 April, 2013 by Tom Elliott

If you have recently changed your WordPress username by using the method of creating a new admin user and deleting the old admin user, or using the Better WP Security plugin, then you may find your established Gravatar profile picture is suddenly missing from all previous post comments.
 
This is because the above methods of changing your WordPress username will rename your admin “user_id” in the WordPress “users” and “usermeta” table, but won’t change the user_id associated with your previous post comments, which means Gravatar won’t display your profile pic belonging to the recently changed admin username.
 
If you can see you Gravatar profile picture from the user list in WordPress admin, and creating a new comment shows the profile pic correctly then the following quick steps should fix your Gravatar picture:
  1. Login to your WordPress database using PHPMyAdmin or whatever database management tool you use
  2. Make a note of your new user ID by finding your user details in the “users” table and checking the “ID” field
  3. Make a note of your old user ID by finding an old admin post comment within the “comments” table and checking the “user_id” field.
  4. Change all instances of the new “user_id” in the “usermeta” table to the old user ID
  5. Change the main ID of your profile in the “users” table to the old user ID

Your Gravatar profile picture should now be back in all its glory for all post comments! You should re-login to WordPress administration now your user details have been changed.

 
Security suggestion: You should use a different user_id from the default “1” by installing the excellent Better WP Security plugin.
 
 


2 Comments

  • Rob Cubbon says:

    This fix worked for me, thank you.

    This is what I got from my host.

    mysql> UPDATE wp_comments SET user_id = ‘XX’ WHERE user_id = ‘1’;

    XX is the new user_id number.

  • Thomas Petty says:

    Hi Tom, I installed the Better WP Security tool, and I like what it’s done so far. Our church website had been brute force attacked, but fortunately didn’t get in. However, the funny thing is that ALL the avatars are missing in the comments. The only id that changed was my admin id (which isn’t “admin” and I never post anything with). I actually see the avatar in Users. But the others who have avatars, and whose ids didn’t change are missing.

    Thoughts?
    Thank you!
    Tom

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    css.php