Clear all

Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:


wpDiscuz Support Forum wpForo Support Forum

How to show MyCred badges under comment author avatar

1 Posts
1 Users
Famed Member Admin
Joined: 8 years ago
Posts: 3994
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:

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
Scroll to top