Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to create custom buddypress notification


  • ashwinkk
    Participant

    @ashwinkk

    Hi, I want to create custom buddypress notification, please guide me how can I create that.

    After lots of research I tried below code, which has not worked.

    $globals = array( 
                'path'          => BP_PLUGIN_DIR, 
                'slug'          => BP_MEMBERS_SLUG, 
                'root_slug'     => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 
                'has_directory' => true, 
                'search_string' => __( 'Search Members...', 'buddypress' ), 
                'notification_callback' => 'bp_members_format_notifications', // here we indicate our function 
            );
    
    function bp_members_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { 
        global $bp; 
     
        switch ( $action ) { 
            case 'new_thanks': 
                // EXAMPLE of using $item_id and $secondary_item_id 
                $thanks_for      = $item_id; 
                $who_thanked     = $secondary_item_id; 
                // then you can use these variables to format output; I didn't do it in this example 
     
                $link = '/members/'.$bp->loggedin_user->userdata->user_nicename.'/'; 
                $return = '<a href="'.$link.'">You\'ve been thanked!</a>'; 
            break; 
        } 
     
        return $return; 
    } 
    
    $userid = $bp->loggedin_user->id;
    bp_core_add_notification('', $userid, $bp->friends->id, 'new_thanks','Hi');

    please guide me where I am doing mistake in above code.
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to create custom buddypress notification’ is closed to new replies.
Skip to toolbar