write widget
-
How can I get a user object using this example
Widget.renderOnlineUsersWidget = async function (widget) { const count = Math.max(1, widget.data.numUsers || 24); const uids = await user.getUidsFromSet('users:online', 0, count - 1); let userData = await user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status']); userData = userData.filter(user => user.status !== 'offline'); widget.html = await app.renderAsync('widgets/onlineusers', { online_users: userData, relative_path: nconf.get('relative_path'), }); return widget; };
-
The uid of the user that loaded the page is in
widget.uid
you can use that to load the user.Widget.myWidget= async function (widget) { const userData = await user.getUserData(widget.uid); widget.html = await app.renderAsync('widgets/myWidget', { userData: userData, relative_path: nconf.get('relative_path'), }); return widget; };
Copyright © 2024 NodeBB | Contributors