Add custom gravatars to your wordPress default gravatar list

Add custom gravatars to your wordPress default gravatar list

By default wordpress has some profile photos. In this tutorial we will show to you to Add custom gravatars to your wordPress default gravatar list.

custom gravatars to your wordPress

Just copy paste following code to functions.php file. This file can be found in your current activated theme folder.

if ( !function_exists('fb_addgravatar') ) {
function fb_addgravatar( $avatar_defaults ) {
$myavatar = get_bloginfo('template_directory').'/images/avatar.gif';
//default avatar
$avatar_defaults[$myavatar] = 'people';

$myavatar2 = get_bloginfo('template_directory').'/images/myavatar.png';
//Avatar for user "admin"
$avatar_defaults[$myavatar2] = 'admin';

return $avatar_defaults;
}

add_filter( 'avatar_defaults', 'fb_addgravatar' );
}
Add custom gravatars to your wordPress default gravatar list
Add custom gravatars to your wordPress default gravatar list

Thanks to WpEngineer for this such great wordpress hack!

I found useful following articles for wordpress plugin developers.

http://codex.wordpress.org/Using_Gravatars

http://codex.wordpress.org/Function_Reference

http://codex.wordpress.org/Function_Reference/add_filter

http://codex.wordpress.org/Plugin_API/Filter_Reference

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.