• 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)
  • 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.