'View Form Submission', // Set the post title. 'post_type' => 'lwp_form_submission', // Set the custom post type. 'post_status' => 'publish', // Set the post status to 'publish'. ); // Insert the post and get the post ID. $post_id = wp_insert_post( $post_data ); // Save the processed fields values as post meta. update_post_meta( $post_id, 'processed_fields_values', $processed_fields_values ); $current_page_id = get_the_ID(); // page submitted on details. $additional_details = array( 'page_id' => $current_page_id, 'page_name' => get_the_title( $current_page_id ), 'page_url' => get_permalink( $current_page_id ), 'date_submitted' => current_time( 'mysql' ), 'read_status' => false, 'read_date' => null, 'contact_form_id' => sanitize_text_field( $contact_form_info['contact_form_id'] ), ); // Save the post meta data. update_post_meta( $post_id, 'additional_details', $additional_details ); // Save the 'contact_form_unique_id'. update_post_meta( $post_id, 'lwp_cfdb_contact_form_unique_id', $contact_form_info['contact_form_unique_id'] ); // Save the page ID. update_post_meta( $post_id, 'lwp_cfdb_page_id', $current_page_id ); // Save the read status. update_post_meta( $post_id, 'lwp_cfdb_read_status', false ); // Save the read date. update_post_meta( $post_id, 'lwp_cfdb_read_date', null ); } // =========================================================================================== }