Enabling the avatar in custom comment types

Few days ago I worked on a project. Client was wanting extra two new types (review & question) at comment form. All things implemented successfully. Only problem was that avatar for review/comment type was not coming at frontend & backend. I researched too much and got that avatar is allowed for comment type only.

But you can enable it without modify the WordPress files. There have a filter “get_avatar_comment_types” and you can alter the default settings. I just applied following PHP code and added into my theme’s functions.php file. It was working like a charm.

/**
 * Enable the avatar for different comment types
 *
 * @package      CoreFunctionality
 * @author       Paul Chinmoy
 * @since        1.0.0
 * @license      GPL-2.0+
 */

add_filter( 'get_avatar_comment_types', 'paul_enable_avatar_comment_types' );
/*
 * @param array $types An array of content types. Default only contains 'comment'.
 */
function paul_enable_avatar_comment_types( $types )
{
	//* here 'review', 'question' are my custom comment types
	return array( 'comment', 'review', 'question' );
}
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.