Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 504799

save_post problem with auto-save

$
0
0

Replies: 0

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 all articles
Browse latest Browse all 504799

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>