WordPress get_avatar filter to match logins

The get_avatar filter hook doesn’t apply only to the user with the ID 1 – I’m assuming you have this idea because of the example from page about the get_avatar at the codex –, but in reality it targets the user according to the context it is used in, so every possible user, not solely … Read more

get_avatar_url() how to reset the default image

Paste below code in function.php file function theme_custom_avatar_url($url, $idOrEmail, $args){ return get_home_url() . ‘/wp-content/uploads/…/profile_image_0.jpg’; } add_filter(‘get_avatar_url’, ‘theme_custom_avatar_url’, 10, 3);

Gender based user avatar

I managed to come up with the answer 😀 Thanks to @Jos function ht1_change_avatar($args, $id_or_email) { $gender = get_user_meta($id_or_email, ‘user_gender’, true); if($gender==’Male’){ $myavatar=”http://localhost:81/matrimony/wp-content/uploads/2020/04/groom.png”; }else{ $myavatar=”http://localhost:81/matrimony/wp-content/uploads/2020/04/bride.png”; } $args[‘url’] = $myavatar; return $args; } add_filter(‘get_avatar_data’, ‘ht1_change_avatar’, 100, 2);

WordPress Custom Local Avatar not showing in comments

I found a solution and now my frontend avatar script is fully functioning. Happy days 🙂 I ended up scrapping the above code and using this. add_filter( ‘pre_get_avatar_data’, ‘wad_avatar_meta’, 10, 2 ); function wad_avatar_meta( $args, $id_or_email ){ $user_avatar_meta_key = ‘avatar’; if( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ){ $id_or_email = get_comment( $id_or_email ); } … Read more

Upload avatar for post comment

WordPress doesn’t have built-in profile pictures (Avatars) by default. See Settings > Discussion in the menu for available options. So you may have a few options: Use Gravatar, as this is bundled in WordPress by default and free but would not require a profile image upload button as its managed separately. Look for an Avatar … Read more