Changer avatar administrateur wordpress hosting

Posted by Bhagwad Park on Feb 10, 2016 | No Comments

By default, WordPress has a neat little feature that allows users to create their own personal icons identifying them when they leave a comment. They do this by signing up at gravatar.com with their email ID and WordPress checks their database whenever someone writes a comment. At the same time, many commenters would not have signed up with gravatar.com and so WordPress has the ability to assign a default gravatar to these individuals. If we go into the “Settings” section of the WordPress dashboard and select “Discussion”, we can scroll down to the “Default Avatar” area and choose what kind of image we want to leave for them.

Changer avatar administrateur wordpress hosting create your own, you can

You can see in the screenshot below that the default gravatar appears next to unknown commenters:

There are a number of services and algorithms that create randomly generated gravatars linked to a person’s specific email ID. But wouldn’t you like to take this opportunity to brand your blog further by creating a unique and memorable gravatar for all commenters who don’t have one of their own? Most blogs simply go with the default “Mystery Person”. So if yours is something different, it helps differentiate you even more.

WordPress has a handy filter that allows us to insert our own image into a particular array, thereby giving us the ability to switch our default gravatar to an image of our choosing. Let’s take a look at how to do this.

Find and Place the New Gravatar

The first step is to create or download the new avatar you want. If you (understandably) don’t want or can’t create your own, you can visit a website like www.avatarsdb.com/ to find one that suits your taste. What’s amazing is that you can even download animated GIF images for your gravatar which will work perfectly fine with the technique I’m about to show you.

For my example, I downloaded an animated GIF called “Cat Rain” and saved it as a “.jpg” file on my desktop. Now we need to decide where in the WordPress blog structure are we going to store it. I wouldn’t advise saving it in the themes folder since those can get overwritten on updates. Personally, I prefer to store it in the “wp-content” folder directly. This has the added benefit of being accessible via the WordPress function “content_url()”.

So open up your FTP program and upload your new default gravatar image to the “wp-content” folder – or any other location that you see fit.

Now comes the fun part. Open up your functions.php file or any other location where you place custom PHP and paste in the following code:

Changer avatar administrateur wordpress hosting If we go into the

Over here, we make use of the filter called “avatar_defaults” and redirect it to our own function. Then we link our image to a variable, add that variable to the “avatar_defaults” array and return it. Note that if you stored your Gravatar image in a different location, you’ll need to change the third line to point to your custom location. Finally, the fourth line gives the handle of the gravatar. Mine is “Cat!”, So you’ll probably want to change that too.

Save this code and reload the “Discussion” settings page we saw earlier. If all has gone well, you should see a new option at the bottom with the name of your custom gravatar as shown here:

Save your settings. The next time you load a post with comments by those who don’t have their own gravatar, you should see your custom image show up next to the name.

As I said before, this even works with animated GIF images so that’s pretty cool!

Enter its URL below to find out now:

About the Author

Bhagwad Park is a technical writer from India and currently resides in Florida. He takes a keen interest in the IT world, the cloud, and also maintains a blog focusing on human rights in the developing world.

Watch this video!

Related articles

Wordpress multi domain hostingMany of our users quickly learn to confidently manage multiple WordPress sites on their own. Some even start managing WordPress sites for clients, friends, and family. Recently, one of our...
Wordpress multisite hosting ukMany of our users quickly learn to confidently manage multiple WordPress sites on their own. Some even start managing WordPress sites for clients, friends, and family. Recently, one of our...
Hosting wordpress on amazon s3 clientThe following procedures will help you install, configure, and secure a WordPress blog on your Amazon Linux instance. This tutorial is a good introduction to using Amazon EC2 in that you have...
Multiple news feeds wordpress hostingRecently, one of our users asked if we could cover how to create a custom Facebook feed in WordPress? You can display Facebook posts from your page or group on your WordPress site to improve...
Collapsible navigation wordpress hostingDo you want to add navigation menus in your WordPress site? Did you know that there is a very easy drag-and-drop menu interface that allows you to create drop-down menus in WordPress. In this...