How to get the current users id in 'addNavigation'
-
Hi,
I'm trying to add an item to the navigation system if the user has a value set against their profile, but I'm not sure how to access the current users ID within the addNavigation hook
plugin.addNavigation = function(header, callback) { User = module.parent.require('./user'); User.getUserField(<<CURRENT USER ID SHOULD GO HERE>>, 'gold_member', function(value) { if(value){ header.navigation.push({ class: "", iconClass: 'fa fa-fw ' + 'fa-plus', "name": "hello", "text": "Add Forum", "title": "hello world", route: "/new_category" }); } callback(null, header); }); } ``` any ideas? Cheers, M
-
Added uid into the data passed to the hook, you can get it with
header.uid
https://github.com/NodeBB/NodeBB/commit/0847eb2c3de0c03917178980f3afef8cb43a3ae4#diff-d41d8cd98f00b204e9800998ecf8427eKeep in mind it will be 0 for users that are not logged in.
Copyright © 2024 NodeBB | Contributors