Ajax for non-logged-in users

I’m working on a plugin that captures some data from a non-logged-in user (such as a Like Button) and enters it into the database based on post_id.

My plugin works fine for logged-in users but non-logged-in users produces a “-1” response in AJAX.

Read More

I’m guessing this has to do with an authentication barrier for writing to the database but I’m looking for a way to work around that.

Any ideas?

EDIT: Here is the code: http://pastebin.com/ghtvJNiW
I’m basing this off the Love-It AJAX plugin by Pippin. He says in the tutorial that this only works for logged-in users but I need to get this to work for non-logged-in users as well.

Related posts

Leave a Reply

1 comment

  1. The wp_ajax_{action} hook only fires for logged in users. For logged-out users the action wp_ajax_nopriv_{action} is triggered on an ajax request – so you need to hook into that as well.