Skip to:

Help with Custom View

  • Deleyna


    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 — 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-id

    Since $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:
    // 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.

    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.

Viewing 1 replies (of 1 total)

  • Robin W


    I have to say I think your programming skills are probably better than mine !

    The views bit hooks to bbp_has_topics, so the args are the key part to get this going, rather than needing to alter php files


    Adding Custom View Shortcode

    for how another user got a custom view with meta data working – I’m a bit tied up at the moment to write the answer, but judging by your post above you should be able to work it out !

    If you don’t then come back and I’ll try and help when I get some time

    If you do, please post the whole solution here in the spirit of sharing – it would be a good one to have for other people, and to add as a plugin to the other plugin.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar