Happens exactly like that in this forum, too.
hearsedriver
Posts
-
Click on search magnifier leads to login, but if logged in search magnifier does nothing, after clicked ... -
nodebb-plugin-write-api - add custom user fieldsWell, I can answer that for myself: it worked!
127.0.0.1:6379> HGETALL user:28 1) "username" 2) "test21" ... 43) "customField1" 44) "123" 45) "customField2" 46) "xxx" 47) "uid" 48) "28"
I could then fetch this field e.g. using:
user.getUserFields(data.uid, ['customField1'], function(err, userData) { // do something with userData.customField1 }
-
nodebb-plugin-write-api - add custom user fieldsWell, I have read some plugin code already, but I have yet to write my own one.
You mean like so?
In
plugin.json
:... "hooks": [ { "hook": "filter:user.create", "method": "createUser" }, { "hook": "filter:user.whitelistFields", "method": "whitelistFields" } ] ...
In my plugin
library.js
:plugin.createUser = function(data, callback) { data.user.customField = data.data.customField; callback(null, data); }; plugin.whitelistFields = function(data, callback) { data.whitelist.push('customField'); callback(null, data); };
-
nodebb-plugin-write-api - add custom user fieldsI am integrating NodeBB into a site which also takes care of registration and login. nodebb-plugin-write-api and nodebb-plugin-session-sharing have worked well for that purpose so far.
Now I need to store some additional fields with a user to interact with the main site. One example is fetching the user's avatar from there.
The write-api documentation states for the v2 Create new user endpoint, "Any other data passed in will be saved into the user hash". Unfortunately, this applies only to NodeBB-known fields: it calls
Users.create
from the NodeBB source which only looks at NodeBB-known fields. Own fields, like "mySiteUserId", are not considered.What is the best way to enhance the user with own fields then when using write-api?
I already had a look at nodebb-plugin-ns-custom-fields but might be a bit too much, as I don't need these fields to be user-editable. I could imagine that there's a much easier way?