Ajax stops working when logged in?

A few things that I see: There’s a space in your first add_action declaration. Should be add_action(‘wp_ajax_wppl_function’, ‘wppl_function’); Have you declared wppl_function to run it? Have you localized your scripts when logged in? Please review the codex entry on wp_ajax_nopriv (action)

wp_localize_script escaping my url – fix or alternative

wp_localize_script() now uses json_encode() which means a multidimensional array will now work for the passed data. And, HTML entity decoding only applies to the first level of the array. Better is an way to use json and default js possibilities from WP. At first, i add the options from the database via script and json_encode … Read more

add_action and Ajax

I skimmed through the plugin’s code and you could try to use the define_public_hooks() method of the Plugin_Name class to register your ajax action callbacks of the Plugin_Name_Public class: /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function … Read more

Async Loading of Custom Posts

Testing is the only way to be sure, but my guess would be that it is not the query itself that is slowing the page load. After you have fetched those 2000 records, you are looping through them. Every time you call get_template_part. This function in turn calls locate_template, which leads to load_template, where you … Read more

Allow AJAX call to other roles than admin

All the WordPress AJAX calls should be handled by the admin-ajax.php, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file: add_action( ‘wp_ajax_prefix_update_post’, ‘prefix_update_post’ ); add_action( ‘wp_ajax_nopriv_prefix_update_post’, ‘prefix_update_post’ ); Be sure to add some validation … Read more

Why would admin-ajax.php redirect to the home page for logged out users?

It only redirects when accessed directly, as do all files located in wp-admin/. AJAX requests should work fine regardless of authentication status. Edit: wp-admin/admin-ajax.php should not redirect in any situation. Perhaps a plugin is redirecting all unauthenticated users to the homepage? By default, accessing files inside wp-admin/ when not logged in should redirect to the … Read more

WooCommerce: Translation lost on AJAX call in Checkout page [closed]

I think I fixed the issue with the following extended function in my plugin: function localize_backend( $locale ) { // set langauge if user is in admin area if( defined( ‘WP_ADMIN’ ) || ( isset( $_REQUEST[‘pwd’] ) && isset( $_REQUEST[‘kau-boys_backend_localization_language’] ) ) ){ // ajax call from frontend if ( ‘admin-ajax.php’ == basename( $_SERVER[ ‘SCRIPT_FILENAME’ … Read more

WordPress Ajax Getting Response “Null”

You are rendering the json data the wrong way. Change the success to the below:– success: function(data) { alert(data.id); // Now you can similarly render the other details like details.success }