David Richied (@davidstriga)

Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • @davidstriga

    Participant

    Sure. I copied the function bbp_buddypress_add_notification() in bbpress > includes > extend > buddypress > notifications.php, pasted it right below itself, made the modifications, and changed the name of the function to bbp_buddypress_add_notification_for_participants.

    function bbp_buddypress_add_notification_for_participants( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0 ) {
    
    	$current_topic_id = bbp_get_topic_id();
    	$ids_of_subs = bbp_get_topic_subscribers($current_topic_id);
    	foreach ($ids_of_subs as $sub_id) {
    		$topic_author_id = $sub_id;
    
    		// Bail if somehow this is hooked to an edit action
    		if ( !empty( $is_edit ) ) {
    			return;
    		}
    
    		// global $bp;
    
    		// Get autohr information
    		// $topic_author_id   = bp_loggedin_user_id();
    		$secondary_item_id = $author_id;
    
    		// Hierarchical replies
    		if ( !empty( $reply_to ) ) {
    			$reply_to_item_id = bbp_get_topic_author_id( $reply_to );
    		}
    
    		// Get some reply information
    		$args = array(
    			'user_id'          => $topic_author_id,
    			'item_id'          => $topic_id,
    			'component_name'   => bbp_get_component_name(),
    			'component_action' => 'bbp_new_reply',
    			'date_notified'    => get_post( $reply_id )->post_date,
    		);
    		bp_notifications_add_notification( $args );
    	 	// Notify the topic author if not the current reply author
    	 	if ( $author_id !== $topic_author_id ) {
    			$args['secondary_item_id'] = $secondary_item_id ;
    
    			bp_notifications_add_notification( $args );
    	 	}
    	 
    	 	// Notify the immediate reply author if not the current reply author
    	 	if ( !empty( $reply_to ) && ( $author_id !== $reply_to_item_id ) ) {
    			$args['secondary_item_id'] = $reply_to_item_id ;
    
    			bp_notifications_add_notification( $args );
    	 	}
    	 }
    }
    add_action( 'bbp_new_reply', 'bbp_buddypress_add_notification_for_participants', 10, 7 );
    

    @davidstriga

    Participant

    Well, I hacked the function bbp_buddypress_add_notification() in bbpress > includes > extend > buddypress > notifications.php which calls bp_notifications_add_notification( $args );
    I also found bbp_get_topic_subscribers($topic_id) which I used to get the ids of users who have subscribed to a topic (not sure if there’s another better way of getting all the ids of users who are part of a topic).
    I plugged those ids into the $args for the previous function with a foreach loop, and I was surprised to get anything back.
    Each user gets a notification (as far as I can tell) when anyone replies to the topic, but they also get extra notifications (from themselves and other users) from one reply. I’ll keep playing around with it.

    @davidstriga

    Participant

    It looks like there’s only one function to notify the author of the thread and none to notify anyone else. I’m sure you already found the function, but just in case, its in bbpress > includes > extend > buddypress > notifications.php

    I would also really like to see this feature implemented.

    @davidstriga

    Participant

    Yeah, you’d assume it would be an obvious feature to include, but maybe there’s something stopping them from implementing it. I think BBPress has its own notifications feature that ties into BuddyPress’ notifications.

    @davidstriga

    Participant

    I haven’t experienced the first problem you mentioned (getting two notifications), probably because I haven’t used BBPress and BuddyPress that much, yet, but I really wish the second part would work: allowing participants (who haven’t created the topic) to get notifications when someone leaves a reply.

    My guess is that the second part just hasn’t been implemented, yet. All the components to create that feature are probably there. Someone just has to create it.
    Maybe they thought it wasn’t necessary since users can choose to receive email notifications?

    @davidstriga

    Participant

    I read through the ticket. It looks like the BuddyPress notifications for BBPress forums really are kind of messed up, but it’s fine. I love the functionality it does have. Not even fb has forums.

    @davidstriga

    Participant

    I have threaded replies enabled, the box ticked, and the forum subscribed, but I am not getting any BuddyPress notifications when someone responds to the topic. @Robkk, It probably is a bug. I wish more people would work on BBPress, but I know you can only go so far with volunteer work (and they did go pretty far! Especially with BuddyPress. BuddyPress is awesome.).

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