Get Each Author's Role With Rest API
I'm attempted to create a custom component that will display each author's role beneath the stock Author component on the message page. Ideally, I'd add the information to the stock Author component, but stock components appear to be untouchable. I feel like I'm close. I've got
<#list restadmin("/users/id/${user.id?c}/roles").roles.role as role> ${role.name} </#list>
But the bold portion is looking at me, myself, and I as the user instead of looking at the message author. It's not as simple as ${author.id?c}. I can't tell if I'm really close to a solution or way off course. Any guidance would be very much appreciated.
Hi,
ok in that case I think it would be ok, I would probably add a check on the name and only show the role if it's equal "Employee" or "Dealer", and not for other roles like "Administrator" or "Moderator".
Back to your question, you could try the following approach:
<#if env.context?? && env.context.message?? && env.context.message.author?? > <#assign author_id = env.context.message.author.id /> <#attempt> <#list restadmin("/users/id/${author_id?c}/roles").roles.role as role> <#if role.name == "Employee"> ${role.name} </#if> </#list> <#recover> </#attempt> </#if>