Skip to:
Content
Pages
Categories
Search
Top
Bottom

calling BP function in bbpress return nothing


  • hosam020
    Participant

    @hosam020

    Hello guys,
    i am using WP Latest
    BP : Version 2.5.2
    BBP : Version 2.5.8
    what i am trying to do is delete the notification when trashing the topic :
    in /WP_Plugin_root/bbpress/includes/topics/functions.php
    Line 3177
    function bbp_trash_topic()
    return nothing
    trying to call bp_notifications_delete_notifications_by_item_id( $args );
    var_dump $args all with parametre
    but seems calling bp function will not work in bbp
    any advice will help thank you

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

  • shanebp
    Moderator

    @shanebp

    Did you try this hook do_action( 'bbp_trash_topic', $topic_id ); found in bbp_trash_topic ?


    hosam020
    Participant

    @hosam020

    @shanebp Thank you for the kindly reply
    Yes i am using it.
    i think you mean i have to call this action in theme funcation ourside the bp localfile.

    unction bbp_trash_topic( $topic_id = 0 ) {
    
    	// Validate topic ID
    	$topic_id = bbp_get_topic_id( $topic_id );
    
    	if ( empty( $topic_id ) || !bbp_is_topic( $topic_id ) )
    		return false;
    
    		$args = array(
    		'user_id'           => 386,
    		'item_id'           => $topic_id,
    		'secondary_item_id' => 0,
    		'component_name'    => 'forums',
    		'component_action'  => 'new_topic',
    		);
    	
    	bp_notifications_delete_notifications_by_item_id( $args );
    
    	do_action( 'bbp_trash_topic', $topic_id );

    Please ignore the args param just added a notification param to see if will delete it
    but never happend
    Sorry for my bad english i hope u understand me.


    hosam020
    Participant

    @hosam020

    Waiting for reply,
    it’s so important to delete notification when deleting Topic, Reply as defualt
    Regards


    shanebp
    Moderator

    @shanebp

    You should not change that function. You should use the hook.

    Try something like this in your theme functions.php:

    function hosam_delete_notification( $topic_id ) {
    
       // you cannot send an array
       // create individual variables
       $user_id = 386;  // etc
    
       bp_notifications_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false );
    
    }
    add_action( 'bbp_trash_topic', 'hosam_delete_notification' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar