Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Get Number of Favorites & Subscription to a topic

@babblebey

Participant

Counting Topic Favorites:


<?php
$topic = bbp_get_topic_id();
$users = get_users() ;
$countfav = 0;
foreach ($users as $user) {
    $topicfav_listarray = get_usermeta ($user->id, 'wp__bbp_subscriptions', true) ;
    $topicfav_list = explode (',' , $topicfav_listarray) ;
    if (in_array ($topic , $topicfav_list))  $countfav++ ;
}
echo $countfav;
?>;

Counting Topic Subscriptions:


<?php
$topic = bbp_get_topic_id();
$users = get_users() ;
$countsub = 0;
foreach ($users as $user) {
    $topicsub_listarray = get_usermeta ($user->id, 'wp__bbp_subscriptions', true) ;
    $topicsub_list = explode (',' , $topicsub_listarray) ;
    if (in_array ($topic , $topicsub_list))  $countsub++ ;
}
echo $countsub;
?>;

Now those are the things that worked.

Thank you, Robin! I hope this helps someone in the future

Skip to toolbar