Skip to:
Content
Pages
Categories
Search
Top
Bottom

Return value in bbp_format_buddypress_notifications()

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

  • LikeBtn
    Participant

    @likebtn

    This seems to be a serious BuddyPress bug.
    Check this out: https://buddypress.trac.wordpress.org/ticket/6669#comment:8

    Hi,
    A trac ticket was already registered for that. The full fix should be included in the upcoming 2.6. If not the wordaround is also mentioned in the ticket.

    https://bbpress.trac.wordpress.org/ticket/2779

    Pascal.


    LikeBtn
    Participant

    @likebtn

    Here is the hack we are using to make our custom filter work:

    <?php
    
    function likebtn_notifications_get_notifications_for_user($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
    {
        global $wp_filter;
    
    	$return = '';
    
        if (count($m) == 3) {
    		// Do something here
    
            // We modify global wp_filter to call our bbPress wrapper function
            if (isset($wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications'])) {
                $wp_filter['bp_notifications_get_notifications_for_user'][10]['bbp_format_buddypress_notifications']['function'] = 'likebtn_bbp_format_buddypress_notifications';
            }
    
        	return $return;
        }
    
        return $action;
    }
    // bbPres has a bug: 
    // https://bbpress.org/forums/topic/return-value-in-bbp_format_buddypress_notifications/
    // https://buddypress.trac.wordpress.org/ticket/6669
    // Filter must be called before corresponding bbPress filter
    add_filter('bp_notifications_get_notifications_for_user', 'likebtn_notifications_get_notifications_for_user', 5, 5);
    
    // Wrapper for bbp_format_buddypress_notifications function as it is not returning $action
    function likebtn_bbp_format_buddypress_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
    {
        $result = bbp_format_buddypress_notifications($action, $item_id, $secondary_item_id, $total_items, $format);
        if (!$result) {
            $result = $action;
        }
        return $result;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar