Thank you very much. Yes, myCred site does suggest few samples of their own and I tried to customize it to the above requirement. I also reviewed Stiofan’s suggested code. But, it doesn’t work to return the badge’s title or image in a test email notification. It’d be great if someone here can suggest corrections, and if not, thanks again for considering!
add_filter( 'mycred_badge_image', 'add_user_badge_template_tag', 10, 3 );
function add_user_badge_template_tag( $html, $image, $badge_object ) {
$html = str_replace( '%display_earnedbadges%', mycred_get_users_badges( $user_id ), $html );
return $html;
}
Or this:
add_filter( 'mycred_badge_image', 'add_user_badge_template_tag', 10, 3 );
// Check if user has a badge
$earned_badge_level = get_user_meta( $user_id, 'mycred_badge' . $badge_id, true );
if ( $earned_badge_level != '' ) {
// User has earned this badge
if ( function_exists( 'mycred_get_badge' ) ) {
// Display user's earned badge
$badge = mycred_get_badge( $badge_id, $earned_badge_level );
if ( $badge->level_image !== false ) {
function add_user_badge_template_tag( $html, $image, $badge_object ) {
$html = str_replace( '%display_earnedbadges%', $badge->level_image, $html );
return $html;
}
}
}
}
Kind regards