Okay
  Public Ticket #2987603
Calendar only visible if logged in
Closed

Comments

  •  2
    publicspace started the conversation

    This seems an excellent plugin.  But I cannot work out a basic problem.  The calendar is only visible if logged in.  I have disabled every other plugin, and still the calendar is not publicly visible, unless logged in.  (It works well when logged in.)  The test page has the simplest shortcode, entered in a shortcode block: [stachethemes_ec].  The Calendar settings are Public for visibility, and logged in for front-end submission.  Can you help?

  •  1
    nicoxygen replied

    hello i have same problem

  •  793
    Zhivko replied

    Hi,

    Try following.

    Open your theme or child-theme functions.php file and add this filter somewhere at the bottom:

    add_filter('stec_admin_ajax_public_verify_nonce', function(){
        return 'false';
    });
    

    Clear your cache if you're using cache plugin.

    Let me know if the problem persists.


    Stachethemes Developer

  •  2
    publicspace replied

    Hi Zhivko

    Major thank you.  I have entered the code you suggested as a Code Snippet, rather than editing the functions.php file.  Sadly it has no effect.  I see 7 errors and 1 warning in the Chrome Inspect Console for the calendar page, and even 6 errors on the Home page.  There are zero errors when I disable the Calendar plugin.  I can send you the Console information.  Please advise.   

  •  1
    nicoxygen replied

    for me after cache deleted the problem persist

    when i unactivate litespeed cache 

    without adding lines in funtcions.php

    it's ok have you an idea ?

  •  793
    Zhivko replied

    @publicspace Priority doesn't really matter because there no other filters from this type. I usually say to put it at the bottom because it will be easier to find if something go wrong. 


    Stachethemes Developer

  •  793
    Zhivko replied

    @nicoxygen 

    Place the filter in your theme functions.php file.

    add_filter('stec_admin_ajax_public_verify_nonce', function(){
        return 'false';
    });

    Then clear your litespeed cache. If the calendar has cache enabled clear it as well.

    This is common problem when cache is enabled the nonce string is being cached as well and if the nonce is expired the events won't show up because the verification does not pass.


    Stachethemes Developer

  •  1
    nicoxygen replied

    when i place in functrions.php

    add_filter('stec_admin_ajax_public_verify_nonce', function(){
        return 'false';
    });

    with litespeed activate and full erase cache

    don't work, i have found another module who explain modification with litespeed can you look

    https://theeventscalendar.com/knowledgebase/k/litespeed-cache/

  •  2
    publicspace replied

    Hi 

    I entered the code you suggested as a Code Snippet (rather than editing the functions.php file) cleared all caches, but it had no effect.  

    I then created a duplicate staging site, and put the code directly into the theme functions.php file.  It had no effect. 

    In the staging site, I have now deactivated all plugins except yours, and it works.  So clearly there is a clash that prevents the calendar and produces the errors and warning in the Console.  I will rebuild the staging site plugin by plugin to see where the clash is, and will get back to you.  Thank you for your continued help.  

  •  2
    publicspace replied

    Hi Zhivko

    After analysing this on a duplicate site, the calendar is now showing publicly (without the additional code). 

    In case it's useful to others:  After deactivating all plugins except yours, the problem then reoccurred when reactivating SiteGround Optimizer.  It is set to Combine and Defer javascript files to ensure performance. So, not wanting to lose the performance, I looked at the scripts identified as errors in the Console, and trialled which scripts needed to be excluded.   

    Deferral: for the Calendar to show, and without errors in the Console, this script needs to be excluded (in addition to 2 already excluded - jquery.min.js  and  jquery-migrate.min.js )
          /wp-includes/js/dist/vendor/moment.min.js

    Combining: for the Calendar to show, and without errors in the Console, these two scripts needs to be excluded: 
          /plugins/stachethemes_event_calendar/assets/js/libs/jquery.mobile.min.js
          /wp-includes/js/dist/vendor/moment.min.js

    Following this, I would like to ask 2 questions:  

    > How can I ensure that the Stachethemes scripts only load on the Calendar page, the Submission form, and the Single Events?  At the moment, all the STEC scripts load on every other page on the site too.  Have I missed an option somewhere?  Or could you give  me a code snippet? 

    > There is one remaining error, currently everywhere.  (I can only remove it by turning off the Combining of scripts, or deactivating your plugin.)  Do you know which file should be excluded from Combining javascript files, to prevent this error?  As you can see above, I have already excluded the script explicitly referenced in the report: 

    Uncaught TypeError: Cannot read properties of undefined (reading 'concat')
        at jquery.mobile.min.js?siteground-async=1&ver=3.2.6:4:3006
        at jquery.mobile.min.js?siteground-async=1&ver=3.2.6:4:3576

    Thank you

  •  1
  •  793
    Zhivko replied

    Scripts by default should load only on the pages where they are needed.

    If they load on all pages make sure "Force load calendar scripts" is turned off in STEC -> General -> Misc tab.


    Stachethemes Developer

  •  2
    publicspace replied

    Yes, that fixes it.  Thank you. 

  •  1
    nicoxygen replied

    can you give me liste of nonce of module please i want to integrate in esi litespeed

  •  793
    Zhivko replied

    In file \shortcodes\stachethemes_ec.php:


        // Add DB nonce
        Stachethemes_Event_Calendar::get_instance()->localize('stec-db-js', 'stecApiNonce', array(
            'nonce' => wp_create_nonce('stecApiVerifyNonce')
        ));

    I assume the "stecApiVerifyNonce" string is what you need.


    Stachethemes Developer