Hi @ramoshe,
Could you please check this snippet and see whether it helps to cover your needs?
<?php
add_action( 'forminator_before_form_render', 'wpmudev_post_data_hide_field_form', 10, 5 );
function wpmudev_post_data_hide_field_form( $id, $form_type, $post_id, $form_fields, $postdata_cls ){
if( $id == 361 ) {
add_filter( 'forminator_field_postdata_markup', 'wpmudev_post_data_hide_field', 10, 5 );
}
}
function wpmudev_post_data_hide_field( $html, $field, $required, $id, $cls ){
return '';
}
add_filter( 'forminator_prepared_data', 'wpmudev_update_post_data_fields', 10, 2 );
function wpmudev_update_post_data_fields( $prepared_data, $module_object ){
if( $module_object->id != 361 ){
return $prepared_data;
}
if( isset( $prepared_data[ 'postdata-1' ] ) ){
$prepared_data[ 'postdata-1' ][ 'post-title' ] = $prepared_data[ 'text-1' ];
$prepared_data[ 'postdata-1' ][ 'post-content' ] = $prepared_data[ 'text-2' ];
}
return $prepared_data;
}
The above snippet helps with populating the fields text-1 and text-2 as post title and post content respectively as noticed here:
$prepared_data[ 'postdata-1' ][ 'post-title' ] = $prepared_data[ 'text-1' ];
$prepared_data[ 'postdata-1' ][ 'post-content' ] = $prepared_data[ 'text-2' ];
You can replace it with your form fields.
In the above snippet, you’ll also need to update the following lines with your form ID. ie:
if( $id == 361 ) {
if( $module_object->id != 361 ){
Suppose the form ID is 123, the above line will be changed to:
if( $id == 123 ) {
if( $module_object->id != 123 ){
The snippet can be implemented as a mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Kind Regards,
Nithin