From a0bdd06a6ae1297a9efe69130347c9a5f2c3fe2d Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 4 Jun 2014 18:55:25 -0400 Subject: [PATCH] filter:user.custom_fields - ability to add custom fields into userData --- src/user/create.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/user/create.js b/src/user/create.js index e6d4a61c97..a7900c7484 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -13,6 +13,8 @@ var async = require('async'), module.exports = function(User) { User.create = function(userData, callback) { + var customFields = {}; + userData = userData || {}; userData.userslug = utils.slugify(userData.username); @@ -79,6 +81,12 @@ module.exports = function(User) { next(); } }, + function(next) { + plugins.fireHook('filter:user.custom_fields', userData, function(err, fields) { + customFields = fields; + next(err); + }); + }, function(next) { plugins.fireHook('filter:user.create', userData, function(err, filteredUserData){ next(err, utils.merge(userData, filteredUserData)); @@ -127,6 +135,8 @@ module.exports = function(User) { 'status': 'online' }; + userData = utils.merge(userData, customFields); + db.setObject('user:' + uid, userData, function(err) { if(err) { return callback(err);