Forminator and ACF fix the error

[ad_1]

   add_action( 'forminator_custom_form_after_save_entry', 'wpmudev_custom_hidden_field_value' );

function wpmudev_custom_hidden_field_value( $form_id, $response ) {

if ( $form_id == 1520 && $response['success']) ! empty( $post_content ) )
// Insert a new post with the data
$post_id = wp_insert_post( array(
'post_title' => $post_title, // Use the dynamic title
'post_content' => $post_content, // Use the dynamic content
'post_type' => 'review', // Replace with your custom post type
'post_status' => 'draft' // Set the post status to 'draft'
) );

// Update the ACF fields with the form data
if ( $post_id )
if ( ! empty( $date ) )
update_field( 'date', $date, $post_id );

if ( ! empty( $rating ) )
update_field( 'rating', $rating, $post_id );

if ( ! empty( $name ) )
update_field( 'name', $name, $post_id );

if ( ! empty( $email ) )
update_field( 'email', $email, $post_id );

if ( ! empty( $phone ) )
update_field( 'phone', $phone, $post_id );

if ( ! empty( $image ) )
update_field( 'image', $image, $post_id );



return $response;

}

this is my code, can you fix my code?
when i submit the form then not save the data. action hook not working.
i am using free version of forminator

  • This topic was modified 1 hour, 12 minutes ago by Nouman Qamar.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer