MyBB Community Forums

Full Version: Getting username
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For anyone that knows how to use this I'm sure it's a simple idea so I'm hoping someone can help.

I'm using Page manager to knock up a form for our bulletin board. The form is simple html using <form>. Rather than have the user enter their name (because after all they will be logged in) how can I get the username to display automatically? I've had a look and found the code {mybb->user['username']} but I'm not sure how to put this within the page itself. CAn anyone give me any pointers please?

Many thanks in advance.
Putting {$mybb->user['username']} anywhere in a template should display it. Or if you mean you want to pre-populate a form field, this will work:

<input type="text" name="name" id="id" value="{$mybb->user['username']}" />
(2013-09-30, 12:42 PM)Matt. Wrote: [ -> ]Putting {$mybb->user['username']} anywhere in a template should display it. Or if you mean you want to pre-populate a form field, this will work:

<input type="text" name="name" id="id" value="{$mybb->user['username']}" />

Thanks for the swift reply. Prepopulating the form was what I was after.

Was just away to say how it didn't work for me then realised the most stupid mistake of all - missed the $. Magic - thanks very much

Wondered if I could pick your brains on something else. Can I do the same with todays date? If so what's the variable name? Thanks again.
Don't think that'll be as easy; the $mybb object is available globally but I think the date is only available if it's set somewhere for a specific purpose (i.e. only if a template needs it, like the header).
Ah well. I'm ahead of my time Wink

Thanks again for your help with this.