Hi @theart8,
I got further feedback and I’m afraid there isn’t an easy workaround to change the current behaviour.
However, a solution would be to pass your custom value ie Acconsento and Non Acconsento to an “Input” field, so that you could display the Input field in the Email notifications.
Once you add the Input field, you’ll need to add “formintar-hidden” class to the input field settings as shown in the following screenshot:
Screenshot at 17:25:13.png
You’ll also have to add a default value to the Input field:
Screenshot at 17:27:18.png
As the default value is what that would display when the “Consent” field isn’t checked.
Once done, apply the following code in order to make it work:
<?php
add_action(
'wp_footer',
function() {
if ( ! is_singular() || ! has_shortcode( get_the_content(), 'forminator_form' ) ) {
return;
}
?>
<script type="text/javascript">
(($)=>{
$(document).ready(function() {
setTimeout(function() {
$( '.forminator-custom-form' ).trigger( 'after.load.forminator' );
}, 100);
$(document).on( 'after.load.forminator',function( e, form_id ) {
var form_id = 5883,
consent = $( <code>#forminator-module-${form_id} input[name="consent-1"</code> ),
input = $( <code>#forminator-module-${form_id} input[name="text-1"</code> );
consent.on( 'change', function() {
var self = $(this);
if ( self.is( ':checked' ) ) {
input.val( 'Acconsento' );
} else {
input.val( 'Non Acconsento' );
}
} );
});
});
})(jQuery);
</script>
<?php
},
999
);
You’ll need to update the Form ID of your form in the above code in the following line:
var form_id = 5883,
Suppose your Form ID is 123, the above code will be:
var form_id = 123,
Also, make sure to update the of the input field. Suppose the ID of your input field is {text-4}, then the above code:
input = $(
#forminator-module-${form_id} input[name=”text-1″);
Will change to:
input = $(
#forminator-module-${form_id} input[name=”text-4″);
You can implement the above code 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
I hope this helps. Have a nice day ahead.
Kind Regards,
Nithin