Leave a Reply

2 comments

  1. I’ve been using this for a while to solve exactly your issue, I think I got it from the codex somewhere. But it works.

    // verify if this is an auto save routine. 
    // If it is our form has not been submitted, so we dont want to do anything
        if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
            return $post_id;
    
  2. I assume this is in a post edit/ post save action, in which case you should add checks for user level and a nonce in there. If you don’t then this can be called in all sorts of places where the post values don’t exist.