• Resolved midwestkel

    (@midwestkel)


    What I am doing is pulling the username and avatar from my vBulletin database based off the user_ID field in the WP database.

    The first comment worked fine pulling my username and avatar and the comment but I tried posting as a different user and it shows that comment as the first username and avatar like the variables didn’t get the new stuff.

    How do I get this to work like a foreach statement? Here is the code in my functions.php file.

    <?php
    function mytheme_comment($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment;
       global $vbulletin;
       global $wpdb; ?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    <div class="comment <?php comment_ID(); ?>">
    <div class="comment-left">
    <?php
      $wp_vb_uid = $wpdb->query("SELECT comment_author FROM wp_comments WHERE comment_ID = '".$comment->comment_ID."'");
      $wp_vb_username = $vbulletin->db->query_first("SELECT username FROM vb_user WHERE userid = '".$wp_vb_uid."'");
      if(!empty($wp_vb_uid)) {
          $avatar_def = $vbulletin->db->query_first("SELECT avatarid FROM " . TABLE_PREFIX . "user WHERE userid = '".$wp_vb_uid."'");
       	  $avatar_rev = $vbulletin->db->query_first("SELECT avatarrevision FROM " . TABLE_PREFIX . "user WHERE userid = '".$wp_vb_uid."'");
          if($avatar_def["avatarid"] != 0)
          {
              $avatar_defurl = $vbulletin->db->query_first("SELECT avatarpath FROM " . TABLE_PREFIX . "avatar WHERE avatarid = '%s'", $avatar_def);
              echo "<img src='https://forum.domain.com/".$avatar_defurl."' class='comment-av' />";
          } else if($avatar_rev["avatarrevision"] != 0) {
              $avatar_rev = $vbulletin->db->query_first("SELECT avatarrevision FROM " . TABLE_PREFIX . "user WHERE userid = '".$wp_vb_uid."'");
              echo "<img src='https://forum.domain.com/customavatars/avatar".$wp_vb_uid."_".$avatar_rev["avatarrevision"].".gif' class='comment-av' />";
          } else {
              echo "<img src='https://forum.domain.com/images/misc/default_avy.jpg' class='comment-av' />";
          }
        }
    ?>
    </div>
    <div class="comment-right">
    <?php if(function_exists('hkTC_comment_title'))
        hkTC_comment_title($comment->comment_ID,'<h4>','</h4>');
    ?>
    <span class="comment-author">Submitted by <a href="https://forum.domain.com/member.php?u=<?php echo $wp_vb_uid; ?>"><?php echo $wp_vb_username["username"]; ?></a></span><br />
    <span class="comment-date"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></span>
    <div class="content">
    <?php comment_text() ?>
    <?php edit_comment_link(__('(Edit)'),'  ','') ?>
    </div>
    </div>
    <br style="clear:both;" />
    <div class="comment-links"><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></div>
    </div>
    <?php
            }
    ?>

    Thanks.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Comment Output Issues’ is closed to new replies.