bp_messages_action_edit_notice()
Handle editing of sitewide notices.
Description
Return
(boolean)
Source
File: bp-messages/actions/notices.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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | function bp_messages_action_edit_notice() { // Bail if not viewing a single notice URL. if ( ! bp_is_messages_component() || ! bp_is_current_action( 'notices' ) ) { return false; } // Get the notice ID (1|2|3). $notice_id = bp_action_variable( 1 ); // Bail if notice ID is not numeric. if ( empty ( $notice_id ) || ! is_numeric ( $notice_id ) ) { return false; } // Bail if the current user doesn't have administrator privileges. if ( ! bp_current_user_can( 'bp_moderate' ) ) { return false; } // Get the action (deactivate|activate|delete). $action = sanitize_key( bp_action_variable( 0 ) ); // Check the nonce. check_admin_referer( "messages_{$action}_notice" ); // Get the notice from database. $notice = new BP_Messages_Notice( $notice_id ); $success = false; $feedback = '' ; // Take action. switch ( $action ) { // Deactivate. case 'deactivate' : $success = $notice ->deactivate(); $feedback = true === $success ? __( 'Notice deactivated successfully.' , 'buddyboss' ) : __( 'There was a problem deactivating that notice.' , 'buddyboss' ); break ; // Activate. case 'activate' : $success = $notice ->activate(); $feedback = true === $success ? __( 'Notice activated successfully.' , 'buddyboss' ) : __( 'There was a problem activating that notice.' , 'buddyboss' ); break ; // Delete. case 'delete' : $success = $notice -> delete (); $feedback = true === $success ? __( 'Notice deleted successfully.' , 'buddyboss' ) : __( 'There was a problem deleting that notice.' , 'buddyboss' ); break ; } // Feedback. if ( ! empty ( $feedback ) ) { // Determine message type. $type = ( true === $success ) ? 'success' : 'error' ; // Add feedback message. bp_core_add_message( $feedback , $type ); } // Redirect. $member_notices = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ); $redirect_to = trailingslashit( $member_notices . 'notices' ); bp_core_redirect( $redirect_to ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.4.0 This function was split from messages_screen_notices(). See #6505. | 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.