nonce_user_logged_out to assign guests unique nonces breaks ajax calls
nonce_user_logged_out to assign guests unique nonces breaks ajax calls
nonce_user_logged_out to assign guests unique nonces breaks ajax calls
Catch Form value at AJAX Form submit
Removing custom physical folders with rmdir
I think it’s because you’re doing your localization in the shortcode which may be messing with the order of things. Instead do this: add_action( ‘wp_enqueue_scripts’, array( $this, ‘frontend_enqueue’ ) ); function frontend_enqueue() { wp_register_script( ‘my-handle’, plugins_url( ‘js/frontend.js’, __FILE__), array( ‘jquery’ ), ‘1.0.0’, true); wp_localize_script(‘my-handle’, ‘ajax_actions’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) )); } Then… add_shortcode( … Read more
If you look at the source of admin-ajax.php, the answer becomes clearer: $action = $_REQUEST[‘action’]; if ( is_user_logged_in() ) { // If no action is registered, return a Bad Request response. if ( ! has_action( “wp_ajax_{$action}” ) ) { wp_die( ‘0’, 400 ); } /** * Fires authenticated Ajax actions for logged-in users. * * … Read more
You’re declaring the AJAX handler inside the shortcode handler. That’s not going to work: admin AJAX requests aren’t processed in the context of a page, so the shortcode won’t be run, so the handler won’t be set up. You’ll need to move the function definition and add_actions out to the top level, not inside wpcode_elementor_shortcode. … Read more
add_post_meta not working within AJAX function
admin-ajax.php won’t load without logging as admin- JSON Parse error: Unexpected EOF
The action wp_enqueue_scripts action hook is only on the frontend: try changing this to admin_enqueue_scripts for the admin (untested): add_action( ‘admin_enqueue_scripts’, ‘cf7_script_and_style’ ); Edit: After looking at the definition for wpcf7_enqueue_scripts(), it turns out that CF7 doesn’t anticipate being loaded in the admin: who would’ve guessed. You’ll need to copy a lot of that file … Read more
If I’m understanding this correctly, the issue seems to lie in the HTML form action attribute, where you’re posting to admin-ajax.php. Because of this, your page is being redirected to that URL. Instead, you should prevent the form submission from redirecting the page by using JavaScript. Your JavaScript code should be like: <script> jQuery(function($){ $(‘#filter’).on(‘submit’, … Read more