Forum Discussion

srujanayeruvaka's avatar
8 years ago

How to hide 'Share' button for Anonymous users?

Hi,

 

Is there a way to hide the 'Share' button from posts/blogs/etc, for Anonymous users? Looking for a way to hide the below component by default for unregistered users.

<component id="external.widget.add-this" />

 

Thanks,

Srujana.

  • ChiaraS's avatar
    ChiaraS
    8 years ago

    srujanayeruvaka

     

    you can create a custom component named external.widget.add-this@override

     

    and add the following code in it:

    <#if user.registered>
    <@delegate/>
    </#if>

    That should only render the component for logged-in users. 

  • Hi srujanayeruvaka  You can use conditional CSS in page initialization script.

    /t5/bizapps/page/tab/community%3Astudio%3Aadvanced%3Ainit

     

    <#if user.anonymous>
    <style>
        .lia-link-navigation.lia-js-add-this-widget {
            display: none;
         }
    </style>
    </#if>

    You can add page. name condition also  If want to hide on a specific page.

     

    • srujanayeruvaka's avatar
      srujanayeruvaka
      Champion

      Thank you for the quick response VikasB!

      I should have been more clear with my question... I would like to know if there is a way to control the loading of this component in the quilt based on whether a user is registered or not.

      The display:none; option is the general approach and we have this solution in place. Just thinking if there is a better or more efficient way to do it. :)

       

      Thank you!

       

      • ChiaraS's avatar
        ChiaraS
        Lithium Alumni (Retired)

        srujanayeruvaka

         

        you can create a custom component named external.widget.add-this@override

         

        and add the following code in it:

        <#if user.registered>
        <@delegate/>
        </#if>

        That should only render the component for logged-in users.