25% off ProSNIPC25OFF

Set Custom Default Avatar

Registers a local image as a new default avatar option and forces it as the site default, replacing the generic mystery-person silhouette.

PHPby SnipCraft
php
<?php
if ( ! function_exists( 'scseed_add_custom_avatar_default' ) ) {
    function scseed_add_custom_avatar_default( $avatar_defaults ) {
        // Place your avatar image in your theme's images/ directory.
        $url = get_stylesheet_directory_uri() . '/images/default-avatar.png';
        $avatar_defaults[ $url ] = __( 'Site Default', 'scseed' );
        return $avatar_defaults;
    }
    add_filter( 'avatar_defaults', 'scseed_add_custom_avatar_default' );
}

if ( ! function_exists( 'scseed_force_custom_avatar_default' ) ) {
    function scseed_force_custom_avatar_default() {
        return get_stylesheet_directory_uri() . '/images/default-avatar.png';
    }
    add_filter( 'pre_option_avatar_default', 'scseed_force_custom_avatar_default' );
}
#avatars#customization#profile#users