publish_post called too early
Try this workaround of this issue without using publish_post hook (using save_post) add_action( ‘save_post’, ‘wpse228941_save_post’ ); function wpse228941_save_post( $post_id ) { if( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) return; if ( “publish” == get_post_status( $post_id ) && ! get_post_meta( $post_id, “se_228941_mailed”, 1 ) ) { do_action( “sm12_publish_post”, $post_id ); update_post_meta( $post_id, “se_228941_mailed”, time() ); } } add_action( … Read more