Can I have a plugin send notifications that are not topic related?
-
I want to send a notification to a group when a certain event is triggered. This notification is not related to any new topic or mention.
For example, I want to send a notification to the admin group when a new user is registered and the nodebb-plugin-newuser-approval plugin is active.
-
Yeah just create the notification with
notifications.create
then usenotifications.pushGroup
and pass the notification object.notifications.create({ nid: 'plugin:new_user:' + theiruid, // a unique notification id bodyShort: 'a new user is waiting approval' path: 'admin/plugins/approval', //clickin the notification will take user to this link from: theiruid // this will cause the new users image to appear with the notification }, function(err, notification) { if (err) { return callback(err); } notifications.pushGroup(notification, 'administrators', callback); });
-
@baris thanks. Creating the notification works but when I click on the notification, it takes me to admin/plugins/approval but with client css applied and settings don't get loaded. Refreshing the page applies the admin css and displays ACP menu.
-
@baris you should detect whenever anything is going to
/admin/...
and automatically open it in a new tab. -
@pichalite looking at the code, that shouldn't be happening. Hmmm...
-
@pichalite Try with https://github.com/NodeBB/NodeBB/commit/f89741636cdad244d38bf2c8dca52054f65c335c
Let me know if that works.