anyone encountered this bug that it will work when you are logged in but once you log out it won’t work anymore.
this is a very simple plugin that will fetch zip code and display the corresponding rate.
here’s the code. https://pastebin.com/TPFYJFCP
TIA!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You want to use wp_ajax_nopriv_ for handling ajax for non-authenticated users:
// logged-out users add_action( 'wp_ajax_nopriv_my_action_search_key_press', 'action_search_key_press_callback' ); // authenticated users add_action( 'wp_ajax_my_action_search_key_press', 'action_search_key_press_callback' );
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0