Help with Custom View
-
I *think* I’m going about this the right way — but I may not be, so any advice will be appreciated.
I’ve moved a long-standing forum group onto bbpress. We’re loving it, but members have asked me to make it work more like our old program. I’ve seen a lot of chatter about view-unread elsewhere. I’m using the plugin https://wordpress.org/plugins/bbpress-unread-posts/ — that hasn’t been updated in forever, but works nicely and gives us what we are used to. It creates a meta-key for each topic, each user: bbpress_unread_posts_last_visit_$user-id with the associated value being the unix timestamp.
Combined with the plugin to go to the first unread post, this works. I’ve also created buttons where the user can reset that meta-key to mark forums as read / unread.
Now I want a custom view, “Unread View”, that will look for topics where
_bbp_last_active_time > bbpress_unread_posts_last_visit_$user-idSince $user-id is dynamic, I’m thinking that I can’t just specify the view in the functions.php file and be happy.
What I’ve done:
added:
—–
// adding custom view for unread
function my_custom_views_init() {
$args = array ();
bbp_register_view( ‘unread-view’, __( ‘Unread View’ ), array( $args ), false );
}
add_action( ‘bbp_register_views’, ‘my_custom_views_init’ );
—–
to my functions.php file.created
unread-view.php based on loop-topics.php with the logic to test if
_bbp_last_active_time > bbpress_unread_posts_last_visit_$user-id
and only show the topic if it is… (I’m not sure if I have the logic right yet, or if this is even the right loop to put the test…)Added a page with the short code
[bbp-single-view id="unread-view"]But there’s clearly a link missing. I need something to tell the system that I want to use my unread-view.php instead of loop-topics.php for “unread-view” ONLY.
And I’m not sure how to do that. I’m clearly missing more than a little bit of the logic here. My programming skills are pretty basic, so any help you can give me would be appreciated.
- You must be logged in to reply to this topic.