-1

We are running an event with around 1000 users who have to submit something every day. When they submit, their email is stored in a list in an option in WordPress.

I have encountered a problem where two users have submitted an entry at the same time - the following function is called twice at the same time:

function tw_add_user_to_submitted_today_list($user_email){

  $tw_settings = get_option("tw_settings");
  if (!in_Array($user_email, $tw_settings['submitted_today'])){
    array_push( $tw_settings['submitted_today'], $user_email);
    update_option("tw_settings", $tw_settings);
  }
}

One of the users is not being added to the list because the list is being overwritten before being resaved.

I'm stuck to think of a better or different way of doing this. Is there a way of checking if a process is already running for example?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.