WordPress admin-ajax.php 302 Redirection error via form

Here’s the “long story short” version of my issue:
I have this newsletter/subscription form that triggers the wp-admin/admin-ajax.php file, however the form wasn’t working when I wasn’t logged into WordPress.
Turns out, the admin-ajax.php file has a 302 going against it.

I have already seen/tested previous resolutions of this problem (namely this one and that one), however none of them were helpful.

Read More

I searched throughout my theme files for any related “wp-admin” protections, I didn’t find anything.
I modified and deactivated both WP Better Security and W3C (as well as various other plugins), nothing changed.
I changed/removed the htaccess, nothing changed.

I’m kind of getting frustrated with this issue.
At this point, I know there’s somewhere in my code something blocking access to admin-ajax.php for “outsiders,” however I can’t figure out where.
It’s either something protecting my admin folder and/or something protect admin-ajax.php.

Any ideas?

Help would be much appreciated.
Thanks in advance!

Related posts

Leave a Reply

1 comment

  1. Ok, the problem here is that WordPress uses two different hooks for ajax. It uses one for admin side, and one for logged out user. My guess is that your form is not using the latter.

    Have a look at the two:

    add_action('wp_ajax_my_action', 'my_action_callback');
    add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
    

    From WordPress Codex:

    Since WordPress 2.8, there is a hook similar to wp_ajax_(action):

    wp_ajax_nopriv_(action) executes for users that are not logged in. So,
    if you want it to fire on the front-end for both visitors and
    logged-in users, you can do this:

    add_action(‘wp_ajax_my_action’, ‘my_action_callback’);
    add_action(‘wp_ajax_nopriv_my_action’, ‘my_action_callback’);

    See here: http://codex.wordpress.org/AJAX_in_Plugins