How to access user data in an outlet connector hbs?

AI-generated summary

The discussion revolves around accessing user data in an outlet connector hbs. hyd504 is trying to render a notice to specific users in the top area of the website and is able to get a static version of the connector to work, but is unable to display the username. hyd504 eventually finds that the user is accessible as currentUser and uses {{{currentUser.displayName}}} to display the username.

Arkshine provides guidance on how to log and view the properties of currentUser. To log data inside a template, use {{log data_here}}, and to access the current user’s data, use the API api.getCurrentUs er(). For example:

<script type="text/discourse-plugin" version="0.8">
  console.log(api.getCurrentUser());
</script>

bchoi28 is also seeking guidance on how to access the current user’s name and display it on a page.

I am working on a plugin that has to render a notice to some specific users in the top area of the website where notices show up. The plugin outlet that I am trying to override is:
{{plugin-outlet name="top-notices" tagName="" args=(hash currentPath=router._router.currentPath)}}

I am able to get a static version of the connector to work. I created the following file at this path: plugins/discourse-user-throttle/assets/javascripts/discourse/templates/connectors/top-notices/throttle_info.hbs



This line is working file. But the username does not show
{{{user.username}}}

The issue I am facing is that the {{{user.username}}} doesn’t username. How can that be done?

I found out using console log that the user is accessible as currentUser:

{{{currentUser.displayName}}}

Hi, any guidance on how to see the properties of currentUser? I can’t seem to figure out how or where to log/view it. I want to be able to access the currentUser’s name and display it on my page.

Hi,

If you mean how to log data inside a template, you can use {{log data_here}} and this should show in the browser console.

You can also use the API: api.getCurrentUser().
For example, in the HTML <head> of your theme/component:

<script type="text/discourse-plugin" version="0.8">
  console.log(api.getCurrentUser());
</script>