Home Forums Backend Issues (wp-admin) Cannot get_field to send in an e-mail


Cannot get_field to send in an e-mail

  • I’m using ACF to my Laravel (Front-end) WordPress (Back-end) Website. I’m using wp-json to retrieve acf values. My only problem is, I have a form (order form from my front-end) that will be stored to my Orders Post Type. I cannot get the acf fields, only the post title, content can be retrieved.

    function send_mail_on_order_submit( $new_status, $old_status, $post ) {
    			if ( 'publish' !== $new_status or 'publish' === $old_status or 'orders' !== get_post_type( $post ) )
    			$service_name = get_field('service_name');
    			$customer_name = get_field('customer_name');
    			wp_mail( '[email protected]',$customer_name . "Empty", $service_name . "Empty" );
    		add_action( 'transition_post_status', 'send_mail_on_order_submit', 10, 3 );
  • Hi @pjpulumbarit

    I am afraid the get_field/the_field expects a second parameter for the post ID otherwise the global post ID values is used.

    Try changing the code as follows and let me know how it goes.

    	$service_name = get_field('service_name', $post_id);
    	$customer_name = get_field('customer_name', $post_id); // where $post_id is the post ID from which you are loading the ACF value. 

    Hope this helps.

  • @pjpulumbarit, Are you having success with using Laravel and WordPress together?

    What are the benefits? Also, do you have a live site(s) that are running using both?

    Any info is greatly appreciated, thanks in advance.

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

The topic ‘Cannot get_field to send in an e-mail’ is closed to new replies.