bp_notifications_action_bulk_manage()
Handles bulk management (mark as read/unread, delete) of notifications.
Description
Return
(bool)
Source
File: bp-notifications/actions/bulk-manage.php
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | function bp_notifications_action_bulk_manage() { // Bail if not the read or unread screen. if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) { return false; } // Get the action. $action = ! empty ( $_POST [ 'notification_bulk_action' ] ) ? $_POST [ 'notification_bulk_action' ] : '' ; $nonce = ! empty ( $_POST [ 'notifications_bulk_nonce' ] ) ? $_POST [ 'notifications_bulk_nonce' ] : '' ; $notifications = ! empty ( $_POST [ 'notifications' ] ) ? $_POST [ 'notifications' ] : '' ; // Bail if no action or no IDs. if ( ( ! in_array( $action , array ( 'delete' , 'read' , 'unread' ) ) ) || empty ( $notifications ) || empty ( $nonce ) ) { return false; } // Check the nonce. if ( ! wp_verify_nonce( $nonce , 'notifications_bulk_nonce' ) ) { bp_core_add_message( __( 'There was a problem managing your notifications.' , 'buddyboss' ), 'error' ); return false; } $notifications = wp_parse_id_list( $notifications ); // Delete, mark as read or unread depending on the user 'action'. switch ( $action ) { case 'delete' : foreach ( $notifications as $notification ) { bp_notifications_delete_notification( $notification ); } bp_core_add_message( __( 'Notifications deleted.' , 'buddyboss' ) ); break ; case 'read' : foreach ( $notifications as $notification ) { bp_notifications_mark_notification( $notification , false ); } bp_core_add_message( __( 'Notifications marked as read' , 'buddyboss' ) ); break ; case 'unread' : foreach ( $notifications as $notification ) { bp_notifications_mark_notification( $notification , true ); } bp_core_add_message( __( 'Notifications marked as unread.' , 'buddyboss' ) ); break ; } // Redirect. bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.