Principle: Find the key name of each notification item. Then specify a key name, set to disable its email notification by default.
The following are examples. The {&key} in the example is to disable “be @” mail notification and “be replied” email notification。
{&key2} is used to disable private discussion email notifications that the “byobu” plugin enables by default.
The penultimate "& event" is used to disable the "Automatically follow the discussion I replied." option that “User Default Preference” plugin enables by default.
- Install extension: fof/User Default Preference
- edit its
extend.php file
use Flarum\User\Event\Registered;
use Flarum\User\User;
use Illuminate\Events\Dispatcher;
return [
function (Dispatcher $events) {
$events->listen(Registered::class, function (Registered $event) {
foreach (['post', 'user'] as $key)
foreach (['byobuPrivateDiscussionCreated','byobuPrivateDiscussionAdded','byobuRecipientRemoved','byobuPrivateDiscussionReplied'] as $key2){
$event->user->setPreference(
User::getNotificationPreferenceKey("{$key}Mentioned", 'email'),
false
);
$event->user->setPreference(
User::getNotificationPreferenceKey("{$key2}", 'email'),
false
);
}
$event->user->setPreference('followAfterReply', false);
$event->user->save();
});
},
];