Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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.

share|improve this question
1  
Please share the relevant code. With the information given, there's no way your problem can be diagnosed at all. –  Johannes Pille Jun 17 '12 at 16:42
    
@Johannes Please see edit. –  AlxVallejo Jun 17 '12 at 16:59

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Wow thank you so much - completely forgot about that. –  AlxVallejo Jun 17 '12 at 18:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.