• Resolved Art

    (@theart8)


    Hi,
    I tried to change with Loco Translate some words in the form data passed via email, but Loco found no packages to translate.

    So I am asking if this email data:

    {consent-1} which says: Checked when the user checked it, and instead it is empty if the user did not check it.

    Is there any way, like a php filter to change this to Acconsento if the user checks it and Non Acconsento if it does not check it so not leave it empty but populate with that word?

    • This topic was modified 2 years, 8 months ago by Art.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @theart8,

    At the moment, there isn’t any out of the box setting to display different text when the content field is selected or not.

    However, I’m checking with our developer to see if there is any workaround that could be suggested regarding this.

    Will keep you posted once we get further feedback.

    Kind Regards,
    Nithin

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    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=&quot;consent-1&quot;</code> ),
    							input = $( <code>#forminator-module-${form_id} input[name=&quot;text-1&quot;</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

    Thread Starter Art

    (@theart8)

    That’s a complex workaround but thank you for providing me that. Eventually I solved by changing the CONSENT element with checkbox and/or radio element, so the user selects one of two options: Acconsento or Non Acconsento.

    It is less beautiful maybe on the front-end, but it works for what I needed so I think we can close this.

    I appreciate your support, keep up the good work you are doing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change word CHECKED in email’ is closed to new replies.