• Extensions
  • FriendsOfFlarum Default User Preferences

[deleted] if what I describe in my post above isn't correct, it should be easy enough to try on a test forum.

25 days later
a month later

This is great. We have a lot of users who don't realise they're being tagged in posts, because they're not actively checking the forum themselves. When they don't see any emails, they assume there's no activity that warrants their attention.

Is there a simple way for me to alter this to iterate through the existing users on the forum, also? Looking at the code, it doesn't look like it should be too difficult - but I don't know where to look in the documentation to give this a go myself.

https://github.com/FriendsOfFlarum/default-user-preferences/blob/master/extend.php

  • ctml replied to this.

    troymccann Might be easier to just replace everyones user settings in the db directly with the default you want, and then after that people can customize and new users get the defaults.

      ctml I was looking into that. Where are they in the database? Closest I could see was preferences stored in a binary blob?

      • ctml replied to this.

        troymccann yeah exactly you got it, the preferences column in the users table. The simplest solution would probably to just set the defaults you'd like on your own profile via the flarum GUI and then run a simple UPDATE to set everyone elses to that. Of course that would overwrite any preferences currently set by the users, but they can always go back and disable them again if needed.

        UPDATE users
        SET preferences = (SELECT preferences FROM users WHERE username = 'troymccann')
        WHERE username != 'troymccann'

          ctml Great idea! Thanks for the tip. 👏

          ctml Of course that would overwrite any preferences currently set by the users, but they can always go back and disable them again if needed.

          Yes, that's my thinking, I wouldn't usually be inclined to alter everyone's personal preferences, if it wasn't for so many of our users commenting that they're missing posts and expecting email notifications but haven't worked out how to set them themselves! I've got a growing push for our community to be moved to Slack, but this should settle things down until I can work out a true push notification solution.

          FYI, if anyone needs to do something similar, you can't run a SQL query within a table that you're updating. There's a cheeky workaround as follows:

          UPDATE users
          SET preferences = (SELECT * FROM (SELECT preferences FROM users WHERE username = 'troymccann') as t)
          WHERE username != 'troymccann'
            5 days later

            I have the opposite problem 😅

            Now, by default in Flarum when new user register, the Email Notification with "someone posts in a discussion I´m following" is active. In my case I prefer it to be disabled by default (only the part for Email). I find it too invasive and spend some resources sending emails. If the user requires it, I prefer that he activate it himself

            I think I remember that someone user create a small extension to leave this option by default deactivated for new users.
            I've looked for it but I can't find it. Someone remember?
            or I may have dreamed it? 😆

            Thanks!

              4 months later

              troymccann
              Looks like this statement is just for a single user. How would I update all users?

              UPDATE users
              SET preferences = (SELECT * FROM (SELECT preferences FROM users WHERE username = 'troymccann') as t)
              WHERE username != 'troymccann'

                lmx This should take your user preferences and set it to everyone else. The username != 'troymccann' condition makes sure all users except troymccann are selected.

                • lmx replied to this.
                • lmx likes this.
                  3 months later
                  2 months later

                  Walys I have the same problem. I prefer to disable all the email notification as well.

                  Then I found the way someone has tired to revise it to disable the default setting of email notification of the private disscusion extension:

                  `
                  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'),
                  true
                  );
                  $event->user->setPreference(
                  User::getNotificationPreferenceKey("{$key2}", 'email'),
                  false
                  );
                  }

                          $event->user->setPreference('followAfterReply', false);
                  
                          $event->user->save();
                      });
                  },

                  ];`

                  3 months later

                  r4nchy the extension has no settings, it just does what is described in the first post when enabled.

                  10 days later

                  1.1.0

                  • Add the ability for the forum admin to specify what the default settings for new users are
                  • Other extensions may register their defaults with this extension, to allow for additional default preferences

                  I plan to add support for this to various FoF extensions in due course. Feel free to request which FoF extensions you'd like to see support added in due course 🙂

                  Note: These default settings only apply to new users, and depend on what defaults are active at the moment on them joining the forum.

                  Updating
                  composer require fof/default-user-preferences:"*"
                  php flarum cache:clear
                  Screenshots

                  Default

                  With fof/nightmode (1.3.3 or later)

                  9 days later

                  1.1.1

                  • Fixes an issue introduced in 1.1.0 where another extension registering it's default preferences using PHP 7.X would cause a fatal error (semihunwin )
                  Updating
                  composer require fof/default-user-preferences:"*"
                  2 months later

                  Thanks for creating this extension. Works great.