0

I'm probably going to butcher explaining what I'm trying to do, so bare with me.

Essentially I'm working on a custom Contest type of solution for a client. I'm using Gravity Forms for the users to sign up, and then I have a hidden field that is able to be populated dynamically through GF. I have a Cron Job set up to where once a day it will populate that field with a value of "winner". However it only needs to be populated for the first user that hits the site after the scheduled job runs, then for the next person it should be blank again.

I've looked into using a session variable, but unless I can pull the session id, I can't exactly make that work correctly. I can't use a query string, as I don't want the user to know if they've won until after they fill out the form, which then it will use the value to show a winner or loser section with javascript.

I'm about 99% sure this is not the best way to go about it, but being somewhat of a PHP newb, this is what the last few days of research has gotten me. Any help would be greatly appreciated.

  • It sounds like what you want is to use a cookie – GhostToast Nov 6 '13 at 18:44
  • @GhostToast I had looked into that, but it appears you can't access a cookie from within a cron job. – Scott Stubblefield Nov 6 '13 at 19:00
0

I'm gonna attempt an answer here:

  1. In your GF code, you're going to need to have a snippet that checks the hidden field in the db first. IF value is blank.. THEN they are not a winner = Proceed. If value is 'winner'.. then update value to blank... Proceed with 'winner' functionality.

  2. In your cron, you are going to update the value to 'winner' once a day, I guess. If someone submits the form.. the value will be updated to blank (per step 1)... and they will be the winner for the day.. until the value is updated to 'winner' again by the cron.

Right??

  • I think that might work. My main issue is I need the "winner" to also be sent along with the form so we can see who won and send them their prize. I've got it tied into a add_action("gform_after_submission", "after_submission", 10, 2); but I don't know for sure if that will send the info, and then remove it for the next user. – Scott Stubblefield Nov 6 '13 at 19:03
  • Post that function into your original question for me to take a look. – josh Nov 6 '13 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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