Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

How to show MyCred badges under comment author avatar

1 Posts
1 Users
1 Reactions
6,391 Views
 Tom
(@tomson)
Famed Member Admin
Joined: 11 years ago
Posts: 4245
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#1]

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