Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Favourites


_ck_
Participant

@_ck_

Here’s a function I whipped up to grab the number of users who call any particular topic a favorite.

If you don’t send it a topic id, it return the currently displayed topic’s favorite count

function get_topic_favorites_count( $topic_id=0) {
global $bbdb, $topic;
if (!$topic_id) $topic_id = (int) $topic->topic_id;
return $bbdb->get_var("SELECT COUNT(*) FROM ".$bbdb->usermeta." WHERE meta_key='bb_favorites' AND meta_value REGEXP ':<:".$topic_id.":>:'");
}

use it this way:

<? echo get_topic_favorites_count(); ?>

within your topic.php template

Skip to toolbar