bp_settings_sanitize_notification_settings( array $settings = array() )
Sanitize email notification settings as submitted by a user.
Description
Parameters
- $settings
-
(Optional) Array of settings.
Default value: array()
Return
(array) Sanitized settings.
Source
File: bp-settings/bp-settings-functions.php
function bp_settings_sanitize_notification_settings( $settings = array() ) { $sanitized_settings = array(); if ( empty( $settings ) ) { return $sanitized_settings; } // Get registered notification keys. $registered_notification_settings = bp_settings_get_registered_notification_keys(); /* * We sanitize values for core notification keys. * * @todo use register_meta() */ $core_notification_settings = array( 'notification_messages_new_message', 'notification_activity_new_mention', 'notification_activity_new_reply', 'notification_groups_invite', 'notification_groups_group_updated', 'notification_groups_admin_promotion', 'notification_groups_membership_request', 'notification_membership_request_completed', 'notification_friends_friendship_request', 'notification_friends_friendship_accepted', ); foreach ( (array) $settings as $key => $value ) { // Skip if not a registered setting. if ( ! in_array( $key, $registered_notification_settings, true ) ) { continue; } // Force core keys to 'yes' or 'no' values. if ( in_array( $key, $core_notification_settings, true ) ) { $value = 'yes' === $value ? 'yes' : 'no'; } $sanitized_settings[ $key ] = $value; } return $sanitized_settings; }
Changelog
Version | Description |
---|---|
BuddyPress 2.3.5 | 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.