Support » Plugin: Mingle Forum » [Plugin: Mingle Forum] PHP code to get number of new Mingle posts

  • kanjipad


    I have replaced the Mingle forum header with a small sidebar widget that has links to:
    (where user_id is appropriately adjusted)
    (where id is appropriate to the logged in user)

    The first of these links loads a table showing new posts, exactly as the equivalent link does in the default Mingle Forum header.

    What I would really like is a way to gray out this link if there are no new posts, and change the mouseover text to indicate the number of new or unread posts. This would save the user from clicking the link only to find there are no new posts.

    I suspect the answer is somewhere in mingle-forum/wpf.class.php but going through someone else’s code is tricky. I assume I would need to go through the same process Mingle uses to create the table, but count the number of new posts instead of outputting them into a table.

    Can anyone here provide some guidance? Is there some pre-written WordPress code I could use to get number of posts since a certain date/time?



Viewing 2 replies - 1 through 2 (of 2 total)
  • kanjipad


    Actually, I am close to solving this myself, based on other non-Mingle threads. The following code works out the number of posts (non-forum posts?) in the last day:

    $allDay = date('Y-m-d H:i:s', strtotime('-1 day'));
        global $wpdb ;
        $numpost = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_date > '$allDay'");

    I could probably attempt something similar with the Mingle posts.



    This seems to work:

    global $mingleforum;
       global $wpdb ;
       $lastvisit = $mingleforum->last_visit();
       $threads = $wpdb->get_results("select distinct($mingleforum-> from $mingleforum->t_posts inner join $mingleforum->t_threads on $mingleforum->t_posts.parent_id = $mingleforum-> where $mingleforum-> > '$lastvisit' order by $mingleforum-> desc");
       $num_new_posts = count($threads, 0);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Mingle Forum] PHP code to get number of new Mingle posts’ is closed to new replies.