Hello Fred Stuurman,
The way that you are using the filter is not the proper way, just to let you know, merging two values into one field is possible but for this you need to know which field is bee retrieved first in the order, then need to take the second value and merge it to the first value and then in next for the second value you need it to make it null, so that the same value is not been populated in the database.
Below is the example.
add_filter( ‘cfdb7_before_save_data’, function ( array $form_data ): array {
$form_data[‘Adres’] = $form_data[‘Adres’].”-“.$form_data[‘Huisnummer’] ;
$form_data[‘Huisnummer’] = “”;
return $form_data;
} );
Also to let you know the format for merging that you were using is not the perfect way. You need to use the PHP standard for merging the values.
If you still have any query, then let us know.
Regards,
Vsourz
Vsourz,
Thanks for the reply, I have tried both ways , filling huisnummer with both values and filling Adres with both.
Also clearing is not done when coded, so:
add_filter( ‘cfdb7_before_save_data’, function ( array $form_data ): array {
$form_data[‘Huisnummer’] = ‘ ‘;
return $form_data;
} );
should empty the huisnummer field, but it is not, what I am missing.
Kind regards
Fred Stuurman
Searched the plugin code and found out that the name of the filter is wrong,
should be vsz_cf7_posted_data
so code will be:
add_filter( ‘vsz_cf7_posted_data’, function ( array $form_data ): array {
$form_data[‘Adres’] = $form_data[‘Adres’] . ‘ ‘ . $form_data[‘Huisnummer’] ;
$form_data[‘Huisnummer’] = ‘ ‘;
return $form_data;
} );This works like a charm.
Kind regards
Fred Stuurman