در بادی پرس به طور پیش فرض برای مواردی هم چون دریافت پیام و… یک ایمیل اطلاع رسانی برای کاربر ارسال می کند . این قابلیت برای بعضی از کاربران خیلی خوشایند نمی باشد و ترجیح می دهند که ایمیل ارسال نشود اما چون هنوز به تنظیمات و بادی پرس آشنا نیستند اغلب دچار مشکل می شوند . برای همین می توانید با استفاده از کد زیر این قابلیت را به طور پیش فرض غیرفعال نمایید و هر کاربری که مایل بود به دلخواه آن ها را فعال نماید .
کد زیر را در فایل bp-custom.php وارد نمایید .
add_action( 'bp_core_activated_user', 'bpdev_set_email_notifications_preference');
function bpdev_set_email_notifications_preference( $user_id ) {
//I am putting all the notifications to no by default
//you can set the value to 'yes' if you want that notification to be enabled.
$settings_keys = array(
'notification_activity_new_mention' => 'no',
'notification_activity_new_reply' => 'no',
'notification_friends_friendship_request' => 'no',
'notification_friends_friendship_accepted' => 'no',
'notification_groups_invite' => 'no',
'notification_groups_group_updated' => 'no',
'notification_groups_admin_promotion' => 'no',
'notification_groups_membership_request' => 'no',
'notification_messages_new_message' => 'no',
);
foreach( $settings_keys as $setting => $preference ) {
bp_update_user_meta( $user_id, $setting, $preference );
}
//that's it. have fun!
}
