Home Forums General Issues add_action – acf/save_post + publish_post


add_action – acf/save_post + publish_post

  • Just looking for some pointers really, I’ve got a function which uses wp_mail to notify users from a ACF user field when a new post is published.

    I was just using the following function;

    add_action( 'publish_post', 'send_content_email' );

    But to retrieve the ACF values I’m having to use;

    add_action( 'acf/save_post', 'send_content_email', 20 );

    Is there a method of merging the two, as acf/save_post is allowing me to retrieve the values however it’s sending the email when a post is saved as a draft, so what I really would like to use is publish_post to send the email when the post goes live.

    Any pointers on how I can achieve this would be appreciated.


  • You can use add_action( 'publish_post', 'send_content_email' ); and use the output of $_POST which should contain all the info you need.

  • I would probably use the ACF hook and check the status of the post in the filter

    if (get_post_status($post_id) == 'publish') {
      // send email

    ’s solution would work as well, but for most people it’s easier to be able to use the acf functions than it is to deal with $_POST

  • I know this is an old post and I have actually submitted a new post in regards to using the publish action with custom post type. I am not able to use $_POST to get the acf values and using acf/save_post only get’s acf fields not wordpress fields like post title and post content. Would it be save to assume that I just need replace all of wp fields like the post title and post content editor with an acf fields?

  • The post fields that you’re talking about are not fields but data in the post table. When using acf/save_post you need to $post = get_post($post_id) and then access the post information from there like $title = $post->post_title. Or you can skip getting the post and use something like $title = get_the_title($post_id)

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘add_action – acf/save_post + publish_post’ is closed to new replies.