1 ) { return '' . __('You have a pending booking','dbem'). ''; } else { return apply_filters( 'bp_em_format_new_booking_notification', '' . sprintf(__('You have %s pending bookings','dbem'), $total_items). '' ); } } break; case 'confirmed_booking': //Count pending bookings if ( $total_items > 1 ) { return apply_filters( 'bp_em_format_confirmed_booking_notifications', '' . __('You have a confirmed booking','dbem'). '' ); } else { return apply_filters( 'bp_em_format_confirmed_booking_notification', '' . sprintf(__('You have %s confirmed bookings','dbem'), $total_items). '' ); } break; case 'cancelled_booking': //Count pending bookings if ( $total_items > 1 ) { return apply_filters( 'bp_em_format_cancelled_booking_notifications', '' . __('A user cancelled a booking','dbem'). '' ); } else { return apply_filters( 'bp_em_format_cancelled_booking_notification', '' . sprintf(__('%s users cancelled bookings.','dbem'), $total_items). '' ); } break; } do_action( 'bp_em_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); return false; } /** * Remove a screen notification for a user. */ function bp_em_remove_screen_notifications() { global $bp; bp_core_delete_notifications_by_type( $bp->loggedin_user->id, $bp->events->slug, 'attending' ); } add_action( 'bp_em_my_events', 'bp_em_remove_screen_notifications' ); add_action( 'xprofile_screen_display_profile', 'bp_em_remove_screen_notifications' ); /** * Catch booking saves and add a BP notification. * @param boolean $result * @param EM_Booking $EM_Booking * @return boolean */ function bp_em_add_booking_notification($result, $EM_Booking){ global $bp; if( get_option('dbem_bookings_approval') && $EM_Booking->status == 0 ){ $action = 'pending_booking'; }elseif( $EM_Booking->status == 1 || (get_option('dbem_bookings_approval') && $EM_Booking->status == 0) ){ $action = 'confirmed_booking'; }elseif( $EM_Booking->status == 3 ){ $action = 'cancelled_booking'; } if( !empty($action) ){ bp_core_add_notification( $EM_Booking->booking_id, $EM_Booking->get_event()->owner, 'events', $action ); } return $result; } add_filter('em_booking_save','bp_em_add_booking_notification',1,2);