See current user/roles during velocity page assembly


I’d like to put some code in my velocity template along the lines of this pseudo code…

#if(user is in role “SuperAdmin” && sys_context=0)
display extra information in page
display extra information in page
do ordinary stuff!

This functionality is only for use when previewing content (I can use sys_context to identify that) - but what I’m trying to do is determine the current users roles during assembly. I know it’s possibly within content editing but I’m not sure how to get the same information during assembly.

Is this possible? Thanks in advance,

Hi David,

I don’t see anything in the Velocity tools / JEXL extensions for doing this, I think an extension would be needed for this.

I’m not sure if it would work though, because I think when assembly is happening the current user is rxserver. I am not sure if that is definitely the case during preview so it is probably worth investigating. It may be easier to accomplish on the JavaScript side.

This older post Getting current username when rendering a velocity template. looks like a similar request.

We’ll experiment a bit and see what we find out.


I actually just did a quick test on this and it can work in Preview from a Velocity extension. At publish time the user will pull as rxserver, so it is only really useful in the Preview context.

Snippet: testUserRole

<h2>User Name: $rx.asmhelper.getUserName()</h2>
#foreach($role in $rx.asmhelper.getUserRoles())


I will pull this in as an enhancement for the next Rhythmyx 7.3.2 Patch. RHYT-1922 is the issue # for tracking.