Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Enable 'Category Notifications' by default?

Hi guys,

I want to setup my forums to default to notify all my users when a new Discussion is added to specific categories. Is that possible via something like:

$Configuration['Preferences']['Email']['MyCategoryName'] = '1';

I see requests from this previously, but no answers...

I don't my SQL hacking for my current users, but would really like to enable this automatically for new users...


  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    I cannot imagine that it is doable by setting a config parameter. But a very small and easy plugin will do.

    Something like that should be enough:

    class YourPluginsNamePlugin extends Gdn_Plugin {
        public function userModel_afterInsertUser_handler($sender, $args) {
                'Preferences.Email.NewDiscussion.X', // replace the X with the category ID

    Please look at an example if you are not sure how a plugin for Vanilla must be named/structured

  • R_J - thanks! That looks really promising...

    But after fiddling a bit, I see this in the UserMeta table:

    Plugin.SetupNotifications.Preferences.Email.NewDiscussion.1 = 1

    So, its prepending "Plugin.SetupNotifications" to the setting I'm trying to do. Makes sense, the code comments say:

         * ++ Before any queries are run, $key is converted to its fully qualified format (Plugin.<PluginName> prepended)
         * ++ to prevent collisions in the meta table when multiple plugins have similar key names.

    Which makes sense, but is also a bummer when I really do want to change pre-existing keys.

    But, all this shows what SQL scripts I need to write, so unless there's an obvious fix, I'll just go that route.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Your plugin is extending the plugin class. If you look at /library/core/class.plugin.php you will find the method setUserMeta with this code:

        protected function setUserMeta($userID, $key, $value = null) {
            $metaKey = $this->makeMetaKey($key);
            $this->userMetaModel()->setUserMeta($userID, $metaKey, $value);

    What you can see is that the function creates a "metaKey" and that is something that you do not want to (I haven't thought of that, sorry)

    But what you can also see is that after transforming the key somehow $this->userMetaModel()->setUserMeta() is called. There is nothing that prevents you from using it directly that way. In my code from the previous post, simply replace $this->setUserMeta( by $this->userMetaModel()->setUserMeta( and that should be all what is needed.

  • BINGO!

    Much appreciated!

Sign In or Register to comment.