• Resolved 306catalyst

    (@306catalyst)


    My form needs to be integrated with Salesforce, and it’s required to have consent (single checkbox) fields. However I noticed that the consent fields have issue sending the entries to Salesforce checkboxes currently, because when checked they send the data as “checked” or “unchecked. For this to work they should send the data as “true” or “false.” However, I need this to be changed only on one form. Not on all forms.

    Can you please tell me how can I change this? I searched in the options there is no such setting.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @306catalyst

    I hope you are well and safe.

    How do you send the form submitted information to Salesforce platform, are you using the webhook integrations?

    There is not any built in settings that allow you to change that however, we may be able to provide you with a custom code to change the behavior.

    Looking forward to hear from you.

    Best Regards,
    Amin

    Thread Starter 306catalyst

    (@306catalyst)

    I’m doing great. Thanks for asking.

    For the integration between Forminator and Salesforce I’m using Bit Integrations plugin, and it works perfectly only when there isn’t any checkbox field. But in this scenario I need to add the consent fields to be sent like boolean to Salesforce.

    It’s ok to add a custom code, it would be of great help to me.

    Thank you,
    Filip

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @306catalyst

    Our developers checked it and provided possible solution. It will require adding a small bit of custom code to the site.

    This is the code:

    <?php 
    add_filter( 'forminator_custom_form_submit_field_data', 'wpmudev_change_consent_field_val', 10, 2 );
    function wpmudev_change_consent_field_val( $field_data_array, $module_id ) {
    	if ( 2960 !== intval( $module_id ) ) { // Please change the form ID.
    		return $field_data_array;
    	}
    
    	$submitted_data = wp_list_pluck( $field_data_array, 'value', 'name' );
    	if ( empty( $submitted_data['consent-1'] ) ) {
    		$field_data_array[] = array(
    			'name'  => 'consent-1',
    			'value' => false,
    		);
    	}
    
    	foreach ( $field_data_array as $key => $value ) {
    		if ( 'consent-1' === $value['name'] && 'checked' === $value['value'] ) {
    			$field_data_array[ $key ]['value'] = true;
    		}
    	}
    
    	return $field_data_array;
    }

    To add it to the site:

    1. create an empty file with a .php extension (e.g. “forminator-salesforce-consent-fix.php”) in the “/wp-content/mu-plugins” folder of your site’s WordPress install on the server

    2. copy above code and paste it into that file

    3. in the code

    a) in this line

    if ( 2960 !== intval( $module_id ) ) { // Please change the form ID.

    replace number 2960 with an ID of your form; form ID is the same number that you can see in form’s shortcode

    b) in this line

    if ( 'consent-1' === $value['name'] && 'checked' === $value['value'] ) {

    replace consent-1 with your consent field ID if it’s different than consent-1

    4. save the file and flush all cache on site.

    It should then work automatically out of the box.

    Best regards,
    Adam

    Thread Starter 306catalyst

    (@306catalyst)

    Thank you very much! This solved my issue!

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hi @306catalyst

    I’m glad to hear it works and I’m happy my colleagues were able to help!

    I’m marking this as resolved then. If you have any other questions, please don’t hesitate to open new topics and we’ll be happy to help.

    Best Regards
    Amin

    Thread Starter 306catalyst

    (@306catalyst)

    Can you please tell me how can I do the same thing for second form on the website that has more consent fields that the first one?

    I tried to upload another PHP file with the second form ID and the codes for it’s consent fields, but after that my website shows “There has been a critical error on this website.” message.

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @306catalyst

    Unfortunately, our support scope has recently changed we no longer can help with custom codes.

    But I can give you some suggestions, to make the code work for another form, you can add multiple files, please just make sure the function name “forminator_custom_form_submit_field_data” is different and unique on each file otherwise you will get an error.

    Another solution is to add your ID like this in the condition part:
    ($module_id_int !== 2960 && $module_id_int !== 1234 && $module_id_int !== 5678 )

    Hope that helps you make the code work.

    Kind Regards
    Amin

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.