Title: save_post problem with auto-save
Last modified: May 8, 2017

---

# save_post problem with auto-save

 *  [mathishuettl](https://wordpress.org/support/users/mathishuettl/)
 * (@mathishuettl)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/save_post-problem-with-auto-save/)
 * Hello,
 * I use the “save_post” hook to do something when a post gets saved. But the hook
   get instantly called when I click on “new post” button in my backend. I only 
   want to do the stuff when a real post gets saved.
 *     ```
       // Autosave, do nothing
       			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 
       					return;
       			// AJAX? Not used here
       			if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) 
       					return;
       			// Check user permissions
       			if ( ! current_user_can( 'edit_post', $post_id ) )
       					return;
       			// Return if it's a post revision
       			if ( false !== wp_is_post_revision( $post_id ) )
       					return;
   
   
                               // my stuff
       ```
   

Viewing 1 replies (of 1 total)

 *  [codismo](https://wordpress.org/support/users/codismo/)
 * (@codismo)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/save_post-problem-with-auto-save/#post-9108128)
 * If you are adding your own custom option in there check the $_POST for that option.
 *     ```
       if ( ! isset( $_POST['your_option_name'] ) ) {
       	return;
       }
       ```
   
 * If not then you could check for the post_title instead.

Viewing 1 replies (of 1 total)

The topic ‘save_post problem with auto-save’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [codismo](https://wordpress.org/support/users/codismo/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/save_post-problem-with-auto-save/#post-9108128)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
