bbPress

Simple, Fast, Elegant

bbPress support forums » Plugins

How to refer to the current topic?

(3 posts)
  • Started 1 year ago by fredvee
  • Latest reply from fredvee
  • This topic is not resolved

No tags yet.

  1. fredvee
    Member

    Hello, trying to get a plugin working hammering here and there... what is the right way to refer to the current topic? I've seen around declaring global $topic and then using it as $topic->topic_id but no go. Any help? I'm trying to inizialize a variable with the id of the topic poster.

    Posted 1 year ago #
  2. What do you mean, no go?

    This code should do it! At a wild guess, remember that globals have to be declared as globals again in each function.

    global $topic;
    $topic_poster_id = $topic->topic_poster;

    It may also be helpful to know that the attributes or whatever they are (things after the ->) correspond to the columns of data in the table.

    Posted 1 year ago #
  3. fredvee
    Member

    Alright! Somehow I had to do like this to get to it:

    global $topic_id;
    $topic = get_topic($topic_id);
    $topic_poster_id = $topic->topic_poster;

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.