Replace Default User Avatar Snippet
This PHP snippet replaces the current default avatar image (orangish circle) with a default image of your choosing.
Please note that the original placeholder image still flashes before your image is loaded when viewing their profile. Unfortunately this is on their side and you can confirm by viewing a members profile here.
This snippet DOES NOT overwrite any custom image the individual may set.
You may ask why not just replace the placeholder image in the assets? Well you can but you will run into two issues. First, it will get overwritten when you update. Second, anything that looks for modified files (FluentAuth) will trigger constant security alerts for such.
In this snippet you will need to update the URL for the image you want to use.
// Define the full URL to your external avatar image.
$external_avatar_url = 'https://YourCustomURLGoesHere.png';
<?php
/**
* Overrides the FluentCommunity default placeholder image with a specific
* externally hosted URL.
* * This code uses the dedicated FluentCommunity filter hook.
* * @param string $default_url The URL the plugin originally intends to use.
* @return string The desired custom external image URL.
*/
function set_custom_fluentcommunity_avatar_url_simple( $default_url ) {
// Define the full URL to your external avatar image.
$external_avatar_url = 'https://YourCustomURLGoesHere.png';
// Define the path of the original image you want to replace/block
$original_placeholder_path = '/wp-content/plugins/fluent-community/assets/images/placeholder.png';
// Check if the current URL being filtered matches the plugin's default placeholder.
if ( strpos( $default_url, $original_placeholder_path ) !== false ) {
// Return your custom URL to replace the default one.
return $external_avatar_url;
}
// For all other URLs (Gravatar, custom avatar), return the URL as is.
return $default_url;
}
// Use a high priority to ensure this runs late and catches the final default URL.
add_filter( 'fluent_community/default_avatar', 'set_custom_fluentcommunity_avatar_url_simple', 999, 1 );
Thak you!

