How to show MyCred badges under comment author avatar
-
In wpDiscuz 3.0.5 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($comment) { $image = ''; 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 $image; } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to show MyCred badges under comment author avatar’ is closed to new replies.