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( 'sm12_publish_post', 'sm12_publish_post' );
function sm12_publish_post( $postid ){
$email = get_post_meta( $postid, '_some_email_address', true );
if( ! $email )
return;
$sub = 'test subject';
$mgs="test message";
wp_mail( $email, $sub, $mgs );
}
Hope it helps.