From b1773ad51d96b8f985386017ac7efbc1c4dc5cde Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 20 Oct 2016 00:53:45 +0300 Subject: [PATCH] add new hook to add more fields to csv download --- src/user/admin.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/user/admin.js b/src/user/admin.js index 6a1eb5f458..3bd9ca1d46 100644 --- a/src/user/admin.js +++ b/src/user/admin.js @@ -30,16 +30,19 @@ module.exports = function (User) { User.getUsersCSV = function (callback) { winston.info('[user/getUsersCSV] Compiling User CSV data'); var csvContent = ''; - + var uids; async.waterfall([ function (next) { db.getSortedSetRangeWithScores('username:uid', 0, -1, next); }, function (users, next) { - var uids = users.map(function (user) { + uids = users.map(function (user) { return user.score; }); - User.getUsersFields(uids, ['uid', 'email', 'username'], next); + plugins.fireHook('filter:user.csvFields', {fields: ['uid', 'email', 'username']}, next); + }, + function (data, next) { + User.getUsersFields(uids, data.fields, next); }, function (usersData, next) { usersData.forEach(function (user) {