How to display notifications for group plugins
-
I created a plugin that allows the members in a group to have a video chat. When the admin starts the chat a notification is send to all the group members:
bp_notifications_add_notification( array( 'user_id'=> $value, 'item_id'=> rand(), 'secondary_item_id' => $bp->groups->current_group->id, 'component_name'=> 'chat', 'component_action'=> 'new_group_chat', 'date_notified'=> bp_core_current_time(), 'is_new' => 1, ) );
The notifications are saved in the database but are not displayed in the notifications page.
This is the function that sets up the global variables for the plugin:function bp_group_chat_setup_globals() { global $bp, $wpdb; /* For internal identification */ $bp->chat->id = 'chat'; $bp->chat->table_name = $wpdb->base_prefix . 'bp_group_chat'; $bp->chat->notification_callback='bp_group_chat_format_notifications'; $bp->chat->slug = BP_GROUP_chat_SLUG; /* Register this in the active components array */ $bp->active_components[$bp->chat->slug] = $bp->chat->id; do_action( 'bp_group_chat_setup_globals' ); } add_action( 'bp_setup_globals', 'bp_group_chat_setup_globals' );
And this is the notifications format function:
function bp_group_chat_format_notifications( $action, $item_id, $secondary_item_id, $total_items) { global $bp; switch ( $action ) { case 'new_group_chat': $group_id = $secondary_item_id; $group_link = bp_get_group_permalink( $group ); $groupSlug=groups_get_slug( $secondary_item_id); $url=home_url( $bp->groups->slug . '/' .$groupSlug . '/' . 'group-chat' ); if ( (int)$total_items > 1 ){ return apply_filters('log_multiple_verifications_notification','' . sprintf( __( '%s group broadcast invite!', 'chat' ), $groupSlug ) . '',$total_items); } else{ return apply_filters('log_single_verifications_notification','' . sprintf( __( '%s group broadcast invite!', 'chat' ), $groupSlug ) . '',$total_items); } break; } do_action( 'bp_group_chat_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); return false; }
Any suggestions?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to display notifications for group plugins’ is closed to new replies.