bp_dtheme_ajax_close_notice()
Close and keep closed site wide notices from an admin in the sidebar, via a POST request.
Description Description
Return Return
(mixed) String on error, void on success
Source Source
File: bp-themes/bp-default/_inc/ajax.php
function bp_dtheme_ajax_close_notice() {
// Bail if not a POST action
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
return;
$nonce_check = isset( $_POST['nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'bp_messages_close_notice' );
if ( ! $nonce_check || ! isset( $_POST['notice_id'] ) ) {
echo "-1<div id='message' class='error'><p>" . __( 'There was a problem closing the notice.', 'buddypress' ) . '</p></div>';
} else {
$user_id = get_current_user_id();
$notice_ids = bp_get_user_meta( $user_id, 'closed_notices', true );
$notice_ids[] = (int) $_POST['notice_id'];
bp_update_user_meta( $user_id, 'closed_notices', $notice_ids );
}
exit;
}
Changelog Changelog
| Version | Description |
|---|---|
| BuddyPress (1.2) | Introduced. |