Okay
  Public Ticket #3738891
Hide subscribe button
Open

Comments

  •  6
    selinkocagoncu started the conversation

    Hello,

    I would like to hide the Subscribe button found on events to be visible+usable only to logged-in users. Is there a way to make this possible?

    Thank you


  •  876
    Zhivko replied

    Hi,

    1) Open your event template with the builder.

    2) Insert "Custom JS" element in the template. You can place it somewhere at the bottom.

    4420775295.png

     

    9616595219.png

    3) Open the Custom JS element settings by clicking on the cogwheel icon.

    8412339803.png

    4) In the JavaScript textarea place the following javascript code:

    (function () {
    
        const userId = STEC_VARIABLES?.current_user?.data?.id;
    
        if (!userId) {
            
            const elementToHide = document.querySelector('.stec-event-share-and-export-subscribe');
    
            if (elementToHide) {
                elementToHide.style.display = 'none';
            }
        }
    
    })();

    5224446060.png

    2116825314.png


    Stachethemes Developer

  •  6
    selinkocagoncu replied

    Thank you very much! I've just realized, would it be possible to do the same thing for the event Comments sections in STEC?

  •  6
    selinkocagoncu replied

    Or make it calendar-specific? So I would be able to set Calendar A as a no-comment calendar, to display before log in, and set Calendar B as the inside calendar..

  •  6
    selinkocagoncu replied

    Hello,

    Thank you very much, the subscribe buttons are now hidden for logged out viewers :) Could you help me do the same for Comments, please?

  •  876
    Zhivko replied

    You can do it via the template builder.

    Open your template.

    Click on the Row Section that wraps the Comments:

    6078385424.png

    Click on the cogwheel button to enter its settings.

    In the Conditions selector add: "Logged-in":

    9945749778.png

     


    Stachethemes Developer

  •  6
    selinkocagoncu replied

    That is perfect! Thank you very much!

  •  6
    selinkocagoncu replied

    Hello,

    I have just realized that the solution below removes the "subscribe" button on desktop, but it is still visible on mobile. 
    (I tried to put it in a row to isolate the subscribe button and set condition, but I guess the Share-Export element cannot be placed in a row)

    Could you help me fix this? I want to ensure that the subscribe button is always hidden for logged out users, irrespective of the device.

    Thank you for your time and attention.

  •  876
    Zhivko replied

    Are you sure it's not old cache on your mobile device?

    The elements share same class name both for desktop and mobile. It doesn't make sense to show on one and be hidden on another.

    Where can I see this issue?


    Stachethemes Developer

  •  6
    selinkocagoncu replied

    Yes, I am fairly certain due to 1) The change to the template through Builder happened weeks ago 2) Clicking on new events never clicked before and in incognito mode gives the same issue

    You can see the issue on the four pages of my site where STEC is displayed:
    artviewmtl.com/home
    artviewmtl.com/fr
    artviewmtl.com/ongoing-expositions
    artviewmtl.com/expositions-en-cours

    When on mobile, viewing a full event by clicking on any month view, box grid, or horizontal slider calendar will display the subscribe button. (cannot verify the Today view currently, as there are no events today, but this can be verified tomorrow, Nov 6, using the same urls)

    Please note that the subscribe button does not display when only the short description is viewed. Similarly, it does not display on box grid view or the slider; it only displays when the full event is viewed.

    Thank you very much for your time and attention.

  •  876
    Zhivko replied

    Try different approach. 

    Remove the custom js code I've sent you earlier and instead place two row sections with logged-in and not logged-in conditions. I'm attaching you a video of what I mean.

    Attached files:  Example.mp4


    Stachethemes Developer

  •  6
    selinkocagoncu replied

    It appears to be solved; thank you very much!