• Resolved mihail1101

    (@mihail1101)


    Hello.

    Problem: I downloaded the “Mycred” plugin. Loaded the “Ranks” addon. Spelled out all the ranks of users, determined which rank for how many comments and other actions. But persistently in comments under nicknames or avatars of users there are no their ranks. I can’t figure out how to get it out!
    What to do? There are still some shortcodes, but it is not clear where to insert them. Either everything breaks, or nothing happens (inserted <?php echo do_shortcode being( ‘[assorted]’ ); ?> such code in different PHP themes).

    And there is a plugin for comments. It contains the code that you need to add to php functions so that it works together with the mycred plugin. I added this code to the end of php functions, but of course nothing has changed.

Viewing 1 replies (of 1 total)
  • Thread Starter mihail1101

    (@mihail1101)

    resolved by code

    
    add_filter('wpdiscuz_after_label', 'wpdiscuz_mc_after_label_html', 110, 2);
    
    function wpdiscuz_mc_after_label_html($afterLabelHtml, $comment) {
       $wpdiscuz = wpDiscuz();
       $userID = $comment->user_id;
       if (!$userID && $wpdiscuz->optionsSerialized->isUserByEmail) {
           $user = get_user_by('email', $comment->comment_author_email);
           if ($user) {
               $userID = $user->ID;
           }
       }
       if ($userID) {
           if (function_exists('mycred_get_users_rank')) { //User Rank
               $rank = mycred_get_users_rank($userID);
               if (is_object($rank)) {
                   $src = $rank->logo_url;
                   $title = $rank->title;
                   $afterLabelHtml .= "<img src='$src' alt='$title' />";
               } else {
                   $afterLabelHtml .= mycred_get_users_rank($userID, 'logo', 'post-thumbnail', array('class' => 'mycred-rank'));
               }
           }
       }
       return '<div class="wpdiscuz-mycred-rank-wrap">' . $afterLabelHtml . '</div>';
    }
    
    • This reply was modified 4 years, 8 months ago by Yui.
    • This reply was modified 4 years, 8 months ago by Yui. Reason: please use CODE button for proper formatting
Viewing 1 replies (of 1 total)
  • The topic ‘Mycred doesn`t work.’ is closed to new replies.