Display Logged in User’s Subscribed Topics
-
Hello!
I would like to display a list of the logged in user’s subscribed forums and topics in my sidebar in order of recent activity (similar to the Recent Activity widget that comes with bbPress).
I’ve been searching around for days and I haven’t figured out a way to do this, nor even a plugin that will do it. I’ve tried creating a custom shortcode, I’ve tried creating a custom widget, and so far the closest thing that has worked is to just copy and paste the code from the user-subscriptions.php template into my sidebar.php. Doing that displays an unformatted version but only when I’m on the user profile page.
Can anyone help? I’m sure there’s some kind of global variable that I’m not calling but I’m not sure what it is. Is there a shortcode I’m missing that will let me display the user’s subscriptions on other pages of the site?
-
If anyone runs into this wondering the same thing, I got this working using this code:
<?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?> <?php if ( bbp_get_user_topic_subscriptions( $uid ) ) : ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php bbp_get_template_part( 'loop', 'topics' ); ?> <?php bbp_get_template_part( 'pagination', 'topics' ); ?> <?php else : ?> <p><?php _e( 'You are not currently subscribed to any topics.', 'bbpress' ); ?></p> <?php endif; ?>
Basically you just have to specify the current user’s ID number in the bbp_get_user_topic_subscriptions function. I’m running into another weird problem that I haven’t been able to fix though: If this is in your sidebar and you view a single forum, it will only display the subscribed topics within that forum.
Hope this helps someone.
Thanks this helped me out!
Hi,
Looking for the same thing, but to show subscribed forums…
Can your code be changed for that?
- You must be logged in to reply to this topic.