BP_REST_Account_Settings_Options_Endpoint::get_notifications_fields()
Get Fields for the Notifications “Email Preferences”.
Description
- From: ‘members/single/settings/notifications’
Return
(array|mixed|void)
Source
File: bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php
public function get_notifications_fields() { $fields = array(); if ( bp_is_active( 'activity' ) ) { $fields_activity[] = array( 'name' => '', 'label' => '', 'field' => '', 'value' => '', 'options' => array(), 'group_label' => __( 'Activity Feed', 'buddyboss' ), ); if ( bp_activity_do_mentions() ) { $fields_activity[] = array( 'name' => 'notification_activity_new_mention', 'label' => sprintf( /* translators: %s: users mention name. */ __( 'A member mentions you in an update using "@%s"', 'buddyboss' ), bp_activity_get_user_mentionname( bp_loggedin_user_id() ) ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_activity_new_mention', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_activity_new_mention', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); } $fields_activity[] = array( 'name' => 'notification_activity_new_reply', 'label' => __( "A member replies to an update or comment you've posted", 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_activity_new_reply', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_activity_new_reply', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_activity = apply_filters( 'bp_rest_account_settings_notifications_activity', $fields_activity ); $fields = array_merge( $fields, $fields_activity ); } if ( bp_is_active( 'messages' ) ) { $fields_messages[] = array( 'name' => '', 'label' => '', 'field' => '', 'value' => '', 'options' => array(), 'group_label' => __( 'Messages', 'buddyboss' ), ); $fields_messages[] = array( 'name' => 'notification_messages_new_message', 'label' => __( 'A member sends you a new message', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_messages_new_message', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_messages_new_message', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_messages = apply_filters( 'bp_rest_account_settings_notifications_messages', $fields_messages ); $fields = array_merge( $fields, $fields_messages ); } if ( bp_is_active( 'groups' ) ) { $fields_groups[] = array( 'name' => '', 'label' => '', 'field' => '', 'value' => '', 'options' => array(), 'group_label' => __( 'Social Groups', 'buddyboss' ), ); $fields_groups[] = array( 'name' => 'notification_groups_invite', 'label' => __( 'A member invites you to join a group', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_invite', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_invite', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_groups[] = array( 'name' => 'notification_groups_group_updated', 'label' => __( 'Group information is updated', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_group_updated', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_group_updated', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_groups[] = array( 'name' => 'notification_groups_admin_promotion', 'label' => __( 'You are promoted to a group organizer or moderator', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_admin_promotion', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_admin_promotion', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_groups[] = array( 'name' => 'notification_groups_membership_request', 'label' => __( 'A member requests to join a private group you organize', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_membership_request', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_groups_membership_request', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_groups[] = array( 'name' => 'notification_membership_request_completed', 'label' => __( 'Your request to join a group has been approved or denied', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_membership_request_completed', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_membership_request_completed', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); if ( function_exists( 'bp_disable_group_messages' ) && true === bp_disable_group_messages() ) { $fields_groups[] = array( 'name' => 'notification_group_messages_new_message', 'label' => __( 'Group Message', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_group_messages_new_message', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_group_messages_new_message', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); } $fields_groups = apply_filters( 'bp_rest_account_settings_notifications_groups', $fields_groups ); $fields = array_merge( $fields, $fields_groups ); } if ( bp_is_active( 'friends' ) ) { $fields_friends[] = array( 'name' => '', 'label' => '', 'field' => '', 'value' => '', 'options' => array(), 'group_label' => __( 'Connections', 'buddyboss' ), ); $fields_friends[] = array( 'name' => 'notification_friends_friendship_request', 'label' => __( 'A member invites you to connect', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_friends_friendship_request', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_friends_friendship_request', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_friends[] = array( 'name' => 'notification_friends_friendship_accepted', 'label' => __( 'A member accepts your connection request', 'buddyboss' ), 'field' => 'radio', 'value' => ( ! empty( bp_get_user_meta( bp_loggedin_user_id(), 'notification_friends_friendship_accepted', true ) ) ? bp_get_user_meta( bp_loggedin_user_id(), 'notification_friends_friendship_accepted', true ) : 'yes' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ), 'group_label' => '', ); $fields_friends = apply_filters( 'bp_rest_account_settings_notifications_friends', $fields_friends ); $fields = array_merge( $fields, $fields_friends ); } $fields = apply_filters( 'bp_rest_account_settings_notifications', $fields ); return $fields; }
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.