Skip to:
Content

Opened 9 years ago

Closed 9 years ago

#201 closed defect (fixed)

How to display topic author instead of last poster?

Reported by: franky_fei@… Owned by: matt
Milestone: Priority: normal
Severity: normal Version: 0.1
Component: Front-end Keywords: function bg|has-patch
Cc:

Description

is there anywhere we can find all functions bbpress support? I try to go through the code but can not find this function: topic_author().

basicly what I want is at the front page display the original topic author instead of the last poster(currently topic_last_poster()), could somebody give me some hints?

thanks, Franky

Change History (5)

comment:1 @tompreuss <tompreuss@…>9 years ago

From what I can tell, function bb_new_topic (found in functions.php) inserts the information you are looking for into the topic_poster_name field for each topic in the bb_topics table:

function bb_new_topic( $title, $forum, $tags = '' ) {
        global $bbdb, $bb_cache, $bb_current_user;
        $title = bb_apply_filters('pre_topic_title', $title);
        $forum = (int) $forum;
        $now   = bb_current_time('mysql');

        if ( $forum && $title ) {
                $bbdb->query("INSERT INTO $bbdb->topics 
                (topic_title, topic_poster, topic_poster_name, topic_last_poster, topic_last_poster_name, topic_start_time, topic_time, forum_id)
                VALUES
                ('$title', $bb_current_user->ID, '{$bb_current_user->data->user_login}', $bb_current_user->ID, '{$bb_current_user->data->user_login}', '$now', '$now', $forum)");
                $topic_id = $bbdb->insert_id;
                if ( !empty( $tags ) )
                        add_topic_tags( $topic_id, $tags );
                $bbdb->query("UPDATE $bbdb->forums SET topics = topics + 1 WHERE forum_id = $forum");
                $bb_cache->flush_many( 'forum', $forum_id );
                bb_do_action('bb_new_topic', $topic_id);
                return $topic_id;
        } else {
                return false;
        }
}

There is no topic_author() function that I could find.

comment:2 @franky9 years ago

thanks, tompreuss ,

so I guess I have to wrote one myself. in the future version, it is cool to add this topic_author() function.

Franky

comment:3 @Franky9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

I added one funciton at template-functions.php,

function topic_first_poster() {

global $topic;
echo bb_apply_filters('topic_first_poster', $topic->topic_poster_name);

}

and it works. I really like bbpress coding style. Great work, and keep going.

comment:4 @tompreuss <tompreuss@…>9 years ago

  • Keywords bg|has-patch added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening so that the patch can be added to the code by the devs.

comment:5 @mdawaffe9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [378]) topic_author() fixes #201

Note: See TracTickets for help on using tickets.