Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter sprzedawczyk

    (@sprzedawczyk)

    I see. One more question: wouldn’t it be possible to use page fragment cache to make is_user_logged_in() inside functions.php work without problems? I know it can be done inside theme files but I would rather do it in functions.php file.

    • This reply was modified 5 years, 5 months ago by sprzedawczyk.
    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    Hi. No. I’m not using nginx but I managed to fix and reproduce the issue.

    It was not a problem with deleting cache or .htaccess files inside /cache/ folder. The thing causing the error was one of my debugging echo lines inside ‘widgets_init’ action filter. To be honest I would never though that it would be the case.

    It’s fixed now, but if you want to check and try to reproduce this error, try this code in functions.php:
    add_action( ‘widgets_init’, ‘xyz_new_widgets’ );
    function xyz_new_widgets() {
    echo “<script>console.log(“.json_encode(var_export(“test_message”, true)).”);</script>”;
    //register_sidebar();
    }

    Thanks for help.

    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    You are right. Details on ‘is_user_logged_in()’ behavior can be found on my previous post. Unfortunately, after deleting my /cache/ folder my cache stopped working all together. I will create separate thread so it wont get mixed up.

    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    Yes, I deleted all /cache/ folder but it’s getting populated again as you know.

    After some debugging I think the problem lies with interaction of is_user_logged_in() function and cache. Maybe “serving old cache” is not the best term for this problem.

    I will try to be as clear as possible:
    – user logs in
    – on pages served using ‘disc cache’, function is_user_logged_in() returns FALSE. After some time and some page refreshing, is_user_logged_in() returns TRUE like the rest of the site and like it should. It’s probably caused by cache reload or something similar.
    – at the same time, on pages with disabled cache like ‘cart’, is_user_logged_in() ALWAYS returns TRUE after login in so it’s working correctly.

    I’m using this filter to monitor is_user_logged_in() behavior.

    add_filter( 'wp_nav_menu_objects', 'demit_filter_wp_nav_menu_objects', 10, 2 ); 
    function demit_filter_wp_nav_menu_objects( $sorted_menu_items, $args ) {
     
    	$is_user_logged_in = is_user_logged_in();
    	$is_user_logged_in_string = var_export($is_user_logged_in, true);
    	echo "<script>console.log(".json_encode(var_export("is user logged in?: " .$is_user_logged_in_string, true)).");</script>";
    	
    	return $sorted_menu_items; 
    }; 

    It’s hard to reproduce this problem because of cache unpredictability so sometimes it’s working like it should.

    I would give you example user login details so the debugging would be easier but I don’t think sharing this publicly would be a good idea.

    • This reply was modified 5 years, 5 months ago by sprzedawczyk.
    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    Thanks for reply. I’m not using any other caching plugin and did not setup any server-side caching. As I said “Don’t cache pages for logged in users” is enabled.
    I did the purging and clearing of cache and the problem persists. Only disabling page caching stops the problem from happening.

    I will leave page caching and debug mode on for testing purposes.
    URL: https://sklep.demit.pl

    From what I’ve seen you can clearly see that user is logged after login in by checking cookies in browser, but he’s sometimes served old cache on some pages not blocked from caching.

    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    My mistake, I forgot about the option in event notification panel.

    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    I don’t know for sure, but I think that I made it to work by purging and removing my cache plugin.

    Thread Starter sprzedawczyk

    (@sprzedawczyk)

    Jedyny pomysł na jaki wpadłem to ustawienie domyślnie metody z paczkomatem i chowanie przycisku “wybierz paczkomat” przy wybieraniu metody z kurierem. Później przy wysyłce produktu trzeba tylko ustawić metode wysyłki zgodną z wybraną przez klienta. Nie brzmi to ładnie, ale nic lepszego ne wymyśliłem. Ogólnie dramat.

    W przypadku paczkomatów na dole są opcje czy chce się je wybrać za pomocą mapy czy listy.

Viewing 9 replies - 1 through 9 (of 9 total)