uo_ceu_show_avatar_in_reports
Filters whether to display the user's avatar in reports, allowing customization of report output.
add_filter( 'uo_ceu_show_avatar_in_reports', $callback, 10, 1 );
Description
This filter hook `uo_ceu_show_avatar_in_reports` controls whether user avatars are displayed in deficiency reports. By default, it returns `false`, meaning avatars are hidden. Developers can return `true` to enable avatar display. This hook fires before user avatars are potentially fetched and displayed within the admin deficiency report template.
Usage
add_filter( 'uo_ceu_show_avatar_in_reports', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Conditionally show user avatars in deficiency reports.
*
* This filter allows administrators to control whether user avatars are displayed
* in the deficiency report output. By default, avatars are not shown.
*
* @param bool $show_avatar The current setting for showing avatars. Defaults to false.
* @return bool True if avatars should be shown, false otherwise.
*/
add_filter( 'uo_ceu_show_avatar_in_reports', function( $show_avatar ) {
// Example: Only show avatars if a specific WordPress option is enabled.
// Let's assume there's an option like 'uo_enable_avatars_in_reports'.
$option_name = 'uo_enable_avatars_in_reports';
// Check if the option is set and its value is 'yes' or true.
if ( get_option( $option_name, 'no' ) === 'yes' ) {
return true;
}
// If the option is not set or not enabled, return the default or original value.
return $show_avatar;
}, 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/classes/backend-deficiency-report.php:193
src/templates/admin-deficiency-report.php:129
// If the group filter is set then only collection user within the group
if ( self::$group && ! isset( $group_user_ids[ $user->ID ] ) ) {
continue;
}
$avatar = '';
if ( true === apply_filters( 'uo_ceu_show_avatar_in_reports', false ) ) {
$avatar = get_avatar_url( $user->ID );
}
$first_name = $user_meta['first_name'][0];
$last_name = $user_meta['last_name'][0];
$email = strtolower( $user->user_email );
foreach ( $user_meta as $key => $value ) {