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
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
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' );