Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi there,
I have some code that outputs the user ID; however, I want it to output the username instead.
@if(CurrentPage.HasValue("author")) { @CurrentPage.author } else { @CurrentPage.WriterName }
"Author" is a property that was created with the user picker.
What should I do. I've tried:
@CurrentPage.author.Name @CurrentPage.author.ToString()
And .ToString() outputs the ID and .Name breaks it.
Any suggestions would be greatly appreciated. Thanks!
Hi Amanda,
You can use the Umbraco helper called @Umbraco.TypedMember to solve this.
You can use the code below to get the name of the member.
@if(CurrentPage.HasValue("author")) { var member = Umbraco.TypedMember(CurrentPage.author); @member.Name } else { @CurrentPage.WriterName }
Hope this helps,
/Dennis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Getting username from user ID
Hi there,
I have some code that outputs the user ID; however, I want it to output the username instead.
"Author" is a property that was created with the user picker.
What should I do. I've tried:
And .ToString() outputs the ID and .Name breaks it.
Any suggestions would be greatly appreciated. Thanks!
Hi Amanda,
You can use the Umbraco helper called @Umbraco.TypedMember to solve this.
You can use the code below to get the name of the member.
Hope this helps,
/Dennis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.