Putting username in header link


I’m trying to add the username into a header link like so:

   <li class='last'><a id="pprefs" href='http://webchat.ghostsirc.net/?channels=kiejr' target="_blank" title="Kiejr Chat" class="nav-link"><span>Chat</span></a></li>
             <script type="text/javascript">
               var currentusername = Discourse.User.currentProp('username');
               document.getElementById("pprefs").href = "http://webchat.ghostsirc.net/?channels=kiejr&nick=" + currentusername;

But the username is coming back undefined, and making the link

It’s probably something minor that I’m not quite getting here.
Help would be much appreciated!

(Vinoth Kannan) #2

May be Discourse not yet ready. Try it inside ember initializer like this ‘alert’ example.