Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get the User ID of a Forum Topic Poster

  • I would like to get the user id of a forum topic poster so that I can display things like cubepoints and rank next to the posters avatar. I have it sort of working but it only shows the points for the logged in user on each post. It doesn’t show the points for the person who actually posted it. Hopefully that makes sense. Here is my code…

    
    <div class="poster-meta">
    <a href=&quot;">
    
    </a>
    
    <span class="cubepoints_buddypress">
    post->poster_id); ?>
    </span>
    <span class="cupepoints_buddypress_rank">Rank -
    post->poster_id); ?>
    </span>
    </div>
    

    This code is in topic.php

Viewing 1 replies (of 1 total)
  • Hello,

    I don’t use the plugins you’re mentioning but in your situation, i think i’ll try to add this code in the functions.php file of my active theme :

    function luke_get_the_topic_post_poster_id() {
    global $topic_template;
    
    return $topic_template->post->poster_id;
    }

    And then i would replace in your topic.php
    post->poster_id); ?>
    by

    and
    post->poster_id); ?>
    by

    I’ve tested to just echo the luke_get_the_topic_post_poster_id() in my topic.php and it seems to work. I think the trouble in your code is that you don’t reference global $topic_template.

Viewing 1 replies (of 1 total)
  • The topic ‘Get the User ID of a Forum Topic Poster’ is closed to new replies.
Skip to toolbar