Jahia in English > How to access the...

0 (0 Good)
0 (0 Bad)

How to access the properties of currently logged-in user?

by  namitgupta »  2012/10/15 11:37

Hi,

I am trying to access the properties of the currently logged-in user (firstname,lastname,email etc) using the following code snippet:

${currentUser.userProperties.properties.firstname}
${currentUser.userProperties.properties.lastname}
${currentUser.userProperties.properties.email}

However, i am not able to retrieve the values from the JCR.

Can i retrieve these values using some Java API's provided by Jahia? 

Please share your thoughts on this.

 

Regards,

Namit Gupta

  • How to access the properties of currently logged-in user?
    2012/10/16 05:33

    namitgupta <p> Hi,</p> <p> I am trying to access the properties of the currently logged-in user (firstname,lastname,email etc) using the following code snippet:</p> <p> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">${currentUser.userProperties.properties.firstname}</span><br style="padding: 0px; margin: 0px; color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; " /> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">${currentUser.userProperties.properties.lastname}</span><br style="padding: 0px; margin: 0px; color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; " /> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">${currentUser.userProperties.properties.email}</span></p> <p> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">However, i am not able to retrieve the values from the JCR.</span></p> <p> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">Can i retrieve these values using some Java API&#39;s provided by Jahia?&nbsp;</span></p> <p> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">Please share your thoughts on this.</span></p> <p> &nbsp;</p> <p> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">Regards,</span></p> <p> <span style="color: rgb(102, 102, 102); font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; font-size: 13px; line-height: 18px; ">Namit Gupta</span></p>

  • Number of messages  36
    Registration date Oct 15, 2012
    0 (0 Good)
    0 (0 Bad)

    Re: How to access the properties of currently logged-in user?

    by  shyrkov »  2012/10/22 21:23

    Hello Namit,

    you can achive it by using:

    ${renderContext.user.properties[j:firstName]}

    ${renderContext.user.properties[j:lastName]}

    ${renderContext.user.properties[j:email]}

    If you are using Jahia 6.6.1.0 you can use the user tag library and its fullName function as follows:

    ${user:fullName(renderContext.user)}

     

    Kind regards

    Sergiy

  • Re: How to access the properties of currently logged-in user?
    2012/10/22 21:23

    shyrkov <p> Hello Namit,</p> <p> you can achive it by using:</p> <p> <font face="Courier New, monospace">${renderContext.user.properties[j:firstName]}</font></p> <p> <font face="Courier New, monospace">${renderContext.user.properties[j:lastName]}</font></p> <p> <font face="Courier New, monospace">${renderContext.user.properties[j:email]}</font></p> <p> If you are using Jahia 6.6.1.0 you can use the <a href="http://www.jahia.com/downloads/jahia/jahia6.6.1/jahia-taglib-6.6.1.0-tlddoc/user/tld-summary.html">user tag library</a> and its <a href="http://www.jahia.com/downloads/jahia/jahia6.6.1/jahia-taglib-6.6.1.0-tlddoc/user/fullName.fn.html">fullName</a> function as follows:</p> <p> <font face="Courier New, monospace">${user:fullName(</font><font face="Courier New, monospace">renderContext.user)}</font></p> <p> &nbsp;</p> <p> Kind regards</p> <p> Sergiy</p>

  • Number of messages  407
    Registration date Oct 22, 2012
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page