Jump to content

How do you grab a users name to input into a custom block?


Recommended Posts

I want to creat a custom welcome block or be able for the site to use a persons user name in various places around the site.  Is there a way to pull the username into custom block?  Something like %username% that would enter the usersname.  I've tried various combinations of %user%, %user_name%, %member%, etc.  Are there commads like this available to use?

Link to comment
Share on other sites

{{if \IPS\Member::loggedIn()->member_id}}
	{expression="\IPS\Member::loggedIn()->name"}
{{else}}
	Guest
{{endif}}

So, this bit of code is basically saying. If a user is currently logged in, it will show their username but if they aren't logged in. It will get replaced with the word guest. 

Edited by Goza
Link to comment
Share on other sites

Thanks for posting!

Unfortunately, this issue is beyond the scope of our technical support. 👩‍💻

Our technical support is happy to help you with the Invision Community platform, but we're unable to help with things like server management, theme questions and modifications.

I've moved this to our Community Support area where other Invision Community owners will see it and help where they can.

Link to comment
Share on other sites

15 hours ago, Jim M said:

Thanks for posting!

Unfortunately, this issue is beyond the scope of our technical support. 👩‍💻

Our technical support is happy to help you with the Invision Community platform, but we're unable to help with things like server management, theme questions and modifications.

I've moved this to our Community Support area where other Invision Community owners will see it and help where they can.

That's sortta dumb... That's something that vBulletin had 20+ years ago. They also had a list of special commands that could be used in posts that would pull different info. Seems like it should be something simple/standard by now.

19 hours ago, Goza said:
{{if \IPS\Member::loggedIn()->member_id}}
	{expression="\IPS\Member::loggedIn()->name"}
{{else}}
	Guest
{{endif}}

So, this bit of code is basically saying. If a user is currently logged in, it will show their username but if they aren't logged in. It will get replaced with the word guest. 

Thank you for this.  Works exactly for what I needed.  Thank you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...