diff --git src/bp-messages/bp-messages-functions.php src/bp-messages/bp-messages-functions.php
index 07b45fb3b..56a1b2193 100644
|
|
|
function bp_messages_dismiss_sitewide_notice( $user_id = 0, $notice_id = 0 ) { |
| 757 | 757 | if ( ! $user_id ) { |
| 758 | 758 | $user_id = bp_loggedin_user_id(); |
| 759 | 759 | } |
| | 760 | |
| 760 | 761 | // Bail if no user is set. |
| 761 | 762 | if ( ! $user_id ) { |
| 762 | 763 | return $retval; |
| … |
… |
function bp_messages_dismiss_sitewide_notice( $user_id = 0, $notice_id = 0 ) { |
| 767 | 768 | } else { |
| 768 | 769 | $notice = BP_Messages_Notice::get_active(); |
| 769 | 770 | } |
| | 771 | |
| 770 | 772 | // Bail if no notice is set. |
| 771 | 773 | if ( empty( $notice->id ) ) { |
| 772 | 774 | return $retval; |
| 773 | 775 | } |
| 774 | 776 | |
| 775 | 777 | // Fetch the user's closed notices and add the new item. |
| 776 | | $closed_notices = bp_get_user_meta( $user_id, 'closed_notices', true ); |
| 777 | | if ( empty( $closed_notices ) || ! is_array( $closed_notices ) ) { |
| 778 | | $closed_notices = array(); |
| 779 | | } |
| | 778 | $closed_notices = (array) bp_get_user_meta( $user_id, 'closed_notices', true ); |
| 780 | 779 | |
| 781 | 780 | if ( in_array( (int) $notice->id, $closed_notices, true ) ) { |
| 782 | 781 | // The notice has already been dismissed, so there's nothing to do. |
| … |
… |
function bp_messages_dismiss_sitewide_notice( $user_id = 0, $notice_id = 0 ) { |
| 786 | 785 | $closed_notices[] = (int) $notice->id; |
| 787 | 786 | $closed_notices = array_map( 'absint', array_unique( $closed_notices ) ); |
| 788 | 787 | $success = bp_update_user_meta( $user_id, 'closed_notices', $closed_notices ); |
| | 788 | |
| 789 | 789 | // The return value from update_user_meta() could be an integer or a boolean. |
| 790 | 790 | $retval = (bool) $success; |
| 791 | 791 | } |