Skip to:
Content
Pages
Categories
Search
Top
Bottom

BBpress like/reply notification


  • zcoin
    Participant

    @zcoin

    I am struggling to implement a plugin / functionality to catch the likes and replies from a source user (giving the like/reply) and notify the destination user (the author of the post) in bbpress, the forum plugin from wordpress.

    Are you aware of existing projects implementing this functionality in bbpress (even partially) ?

    Which mechanisms / plugins are better to use to trigger actions in the frontend in this case? On the other hand, is it a better approach to put triggers on the database column?

    I am more analyzing the database…it has good information, such as user id of the source user, post id. I am talking about the wp_posts table. However, the parent_post is the first post of the topic, so it is not the ierarhical parent post. I need somehow to identify the nested replies from the database, but I dont find the needed information there…

    Thank you for your suggestions !

Viewing 11 replies - 1 through 11 (of 11 total)

  • zcoin
    Participant

    @zcoin

    I think I can set triggers on the wp_posts table. The problem is the concept of parent_post.

    If you have the structure of posts:

    A
    B – C
    – D
    E

    In wp_posts, A is considered the parent_post and B,C,D and E are considered replies.

    However, in bbpress, I am following a different concept forum-like, where B is considered the parent of C and D.

    This piece of info is not in the DB. How can I add a column in wp_posts where I keep the “real” parent of each post?

    @zcoin,
    bbPress is not different from WordPress. Basic information on the post (a forum, a topic or a reply are all a ‘post) is a record inside the wp_posts table. Then in the wp_postmeta table you will find more information for every post.


    zcoin
    Participant

    @zcoin

    Hi Pascal,

    Yes, I see that, the problem is that I don’t want to query wp_postmeta just for the “real parent” post (meaning not the parent from wp_posts aka the first post of the topic, but the post being one level up). I am surprised bbPress does not have a separate table. I wanted to avoid performance problems while quering a large table such as the meta table.

    Thanks,
    Z


    Robin W
    Moderator

    @robin-w

    there is a hook in the new reply handler you can link to

    do_action( ‘bbp_new_reply’, $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to );

    you could just create your own table and post the data there.


    zcoin
    Participant

    @zcoin

    Thank you for the response, I grepped the whole project and I cannot find the hook you mentioned in your previous post.

    But I found in …./bbpress/includes/replies/functions.php the handlers for _bbp_reply_to. I should identify the place where wp_postmeta is populated so I can update my own table as you suggested. If I save the _bbp_reply_to information, I can avoid querying the huge meta table.

    PS: I identified a corner case (hope not a bug). _bbp_reply_to gives the “real” parent of the post, but not in the case of the topic post (the first one from the topic).


    Robin W
    Moderator

    @robin-w

    the hook is in

    includes/replies/functions.php line 424


    zcoin
    Participant

    @zcoin

    Thank you for the response. I used it to populate my own table.

    On the other hand, there is a second option, maybe more optimized: from phpmyadmin, I created a trigger to populate my table when the information I am interested comes in.


    zcoin
    Participant

    @zcoin

    As a conclusion, I couldnt find any free plugin for reply / likes notifications to the user. I had to create one.


    Robin W
    Moderator

    @robin-w

    As a conclusion, I couldnt find any free plugin for reply / likes notifications to the user. I had to create one.

    would you be happy to share it to help others ?


    zcoin
    Participant

    @zcoin

    Yes, I would like to , I am checking how to port my code to a standalone plugin


    zcoin
    Participant

    @zcoin

    The whole logic is on how to get the notifications from your own table synch with the posts table:

    global $wpdb;
    		$results = $wpdb->get_results( "SELECT notif.*, p2.post_title, p2.post_name
    								FROM YOUR_NOTIF_TABLE notif 
    		            INNER JOIN wp_posts p on p.id = (CASE WHEN notif.parent_id > 0 THEN notif.parent_id ELSE notif.topic_id END) 
    								INNER JOIN wp_posts p2 on notif.topic_id = p2.id     
    								WHERE p.post_author = $current_user->ID
    								AND notif.user_source != $current_user->ID
    								AND notif.unread = 1");
    								
    		$reply_notifications = array(); 
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Skip to toolbar