Support

Account

Home Forums General Issues get_field() not returning any values in publish_post

Unread

get_field() not returning any values in publish_post

  • `function send_mails_on_publish( $ID, $post )
    {
    $title = $post->post_title;
    $customer_name = get_field(‘customer_name’, $ID);
    $customer_name_2 = $_POST[‘acf’][‘field_5ad6a41972c01’];
    $customer_name_3 = get_field(‘field_5ad6a41972c01’, $ID);

    $subject = “Your ” . $title . ” Order is successfully submitted.”;
    $message = “Good day Mr./Ms. ” . $customer_name . $customer_name_2 . $customer_name_3 .”!\n\nYour order for is submitted. Please wait for the processing of your order. Thank you!” ;
    wp_mail(‘[email protected]’, $subject, $message );
    }

    add_action( ‘publish_orders’, ‘send_mails_on_publish’, 10, 2 );
    add_action( ‘acf/save_post’, ‘send_mails_on_publish’, 20 );

    I want to get the fields from a recently published Order. I was able to get the post ID and title but $customer_name, $customer_name_2 and $customer_name_3 doesn’t show any values. I am using ACF Pro.

Viewing 1 post (of 1 total)

The topic ‘get_field() not returning any values in publish_post’ is closed to new replies.