Forum Discussion

Suchith's avatar
6 years ago

Restricting Custom Component Only on User Profile Page.

Hi,

So far I have added a custom component in view profile page and able to view it. But I want to restrict the content only when the user views his profile and not on others user profile. 

Please let me know how can I implement this condition.

Thanks

  • Suchith's avatar
    Suchith
    6 years ago

    Hi Prasanth,

    I tried with the above condition, but got an error.

    Please let me know if you need complete stack trace.


    Updated:

    Got it!! 

    <#assign currentProfileId = page.context.user???then(page.context.user.id, user.id) />

    <#if user.id == currentProfileId >

    </#if>

    This worked.



    Thanks

  • Suchith,

    You can add this condition to your custom component for user profile page.

      <#if user.id == page.context.user.id>
     User profile

    <#else>

    Someone else profile

    <#if>

    • Suchith's avatar
      Suchith
      Ace

      Hi Prasanth,

      I tried with the above condition, but got an error.

      Please let me know if you need complete stack trace.


      Updated:

      Got it!! 

      <#assign currentProfileId = page.context.user???then(page.context.user.id, user.id) />

      <#if user.id == currentProfileId >

      </#if>

      This worked.



      Thanks