Notifications
Clear all

How to show MyCred badges under comment author avatar

1 Posts
1 Users
1 Likes
4,740 Views
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4168
Topic starter  

Since wpDiscuz 3.0.5 version we've added a filter hook which allows to show MyCred badges under comment author avatar. But we couldn't add the whole MyCred code in wpDiscuz core files, that would be a hard integration which is not recommended. So please put this code in your current active theme's functions.php file in order to display those badges:

<?php
add_filter('wpdiscuz_after_label', 'add_wpd_mycred_badges', 110);
function add_wpd_mycred_badges($args) {
   $image = ''; $comment = $args[1];
   if (is_null($comment)) return $image;
   if (function_exists('mycred_get_users_rank') && $comment->user_id) { $image .= mycred_get_users_rank($comment->user_id, 'logo', 'post-thumbnail', array('class' => 'mycred-rank')); }
   if (function_exists('mycred_get_users_badges') && $comment->user_id) { $users_badges = mycred_get_users_badges($comment->user_id); if (!empty($users_badges)) { foreach ($users_badges as $badge_id => $level) $image .= '<img src="' . get_post_meta($badge_id, 'main_image', true) . '" width="24" height="24" class="mycred-badge earned" alt="' . get_the_title($badge_id) . '" title="' . get_the_title($badge_id) . '" />'; } }
   return array($image,$comment);
}
?>

   
Della reacted
Quote
Share:
Scroll to top