Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get the User ID of a Forum Topic Poster

  • Avatar of LukeJJones
    LukeJJones
    Member

    @lukejjones

    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…

    `

    <a href="”>


    post->poster_id); ?>

    Rank -
    post->poster_id); ?>

    `
    This code is in topic.php

Viewing 1 replies (of 1 total)
  • Avatar of imath
    imath
    Moderator

    @imath

    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)

You must be logged in to reply to this topic.