How get all Users when the plugins is installed
-
I need to get all users when that plugin is installed so I used this hook ( in my plugin.json):
"hook": "action:plugin.activate", "method": "caricaVecchiBookmark"
In my library.js
converter.caricaVecchiBookmark = function(data, callback) { console.log("ENTRARE QUI DENTRO"); async.waterfall([ function(next) { db.getSortedSetRangeWithScores('username:uid', start, stop, next); } ], function(err, array_uid) { if (err) { return callback(err); } console.log("ARRAY UDI " + JSON.stringify(array_uid)); return callback(null,data); }); };
The problem is that in the shell I can't read the console.log and I don't know why. When I click the activate button in my admin panel, I don't read the console.log. Anyone can help me?
-
@Doppy Ciao Doppy!
At first sight, you're trying to access to
uid
, that is not declared anywhere. So probably if you check in the log of nodebb, it says that cannot load the plugin (or that there were errors). Instead if it's loaded correctly, I don't know what's happening .Probably you should use
data.uid
?I don't really get what you want to do to be honest. Or probably I just don't know how the
action:plugin.activate
hooks works ^^' -
@Doppy make sure you're running with
./nodebb dev
, so you get a realtime log. -
Those hooks weren't working the way they were meant to, that's why they are deprecated. If you need to do a one time operation when the plugin is installed. Just set a flag in the database stating that the operation is done so it is not repeated on every restart of NodeBB.