Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to refer to the current topic?

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    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;

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar