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

I am using the wp-polls plugin on my website. This plugin relies on using AJAX requests of the form http://www.myfakewebsiteurl.com/wp-admin/admin-ajax.php?action=polls&view=process&poll_id=2&poll_2=8&poll_2_nonce=420d75e659

When I log in, this request works fine: it pulls the poll results from the server, and then displays them on the desired web page.

However, when I log out, this request redirects me to the home page. Thus, instead of the poll results appearing, I get the home page loaded where the poll results are supposed to be.

Why would admin-ajax.php redirect visitors to my WordPress-powered site who are not logged in to the home page of my website?

3 Answers
3

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 login page.

Leave a Comment