Skip to:
Content
Pages
Categories
Search
Top
Bottom

notification_callback not working


  • Nithin K Varrier
    Participant

    @nithin270

    Hi,

    I’m trying to create custom notification in my plugin.

    created this function in Class:
    public function setup_globals( $args = array() ) {
    global $bp;
    $sr_notifications_test_slug = ‘sr_notifications_test’;
    parent::setup_globals( array(
    ‘id’ => ‘sr_notifications_test’,
    ‘slug’ => $sr_notifications_test_slug,
    ‘notification_callback’ => array( $this, ‘sr_format_notifications_test’ )
    ) );

    /* Register this in the active components array */
    $bp->active_components[$sr_notifications_test_slug] = ‘sr_notifications_test’;

    }

    created following function :

    function sr_format_notifications_test( $action, $item_id, $secondary_item_id, $total_items, $format = ‘string’ ) {

    switch ( $action ) {
    case ‘my_test’:
    $link = get_permalink( $item_id );
    $text = “Test Notification”;

    $return = apply_filters( $filter, array(
    ‘text’ => $text,
    ‘link’ => $link
    ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
    break;
    }

    do_action( ‘sr_format_notifications_test’, $action, $item_id, $secondary_item_id, $total_items );
    return $return;
    }

    Notification added to DB:
    bp_notifications_add_notification( array(
    ‘user_id’ => $user_id,
    ‘item_id’ => $activity->id,
    ‘secondary_item_id’ => $activity->user_id,
    ‘component_name’ => buddypress()->activity->id,
    ‘component_action’ => ‘my_test’,
    ‘date_notified’ => bp_core_current_time(),
    ‘is_new’ => 1

    ) );

    Please help call back function is not calling.

    Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘notification_callback not working’ is closed to new replies.
Skip to toolbar