Change how the fields show in the email received from Forminator

Need to change how the fields show in the email received from Forminator. I want to change what the plugin does with the data.
I want to know which PHP files I need to look at. For instance, when I do a file upload it includes a link. I want to show the actual image.
It is the main requirement at this moment, so when it builds the response, instead of buildign an element, I will build an <img> element.
Is there a safe way to include this change while preserving the ability to keep plugin updated?
I don't mind doing the coding - just need to know which files to look at and if I can do it in a manner that doesnt break updates.

  • Adam Czajczyk
    • Support Gorilla

    Hi Willem

    I hope you're well today and thank you for your question!

    Currently this is not doable yet. I've checked and apparently there are also no filter hooks to let you change the way those variables (placeholders) that are used in notifications are being replaced with values.

    We've already added this to our "to-do" list so in future versions there should be such filters added (letting you easily change the way variables are replaced). As for now, I've asked our developers to check if there'd be some workaround for this with some custom code and I'm waiting for directions from them.

    Please keep an eye on this ticket and we'll update you here as soon as we get to know more from them.

    Best regards,
    Adam

  • Konstantinos Xenos
    • Rubber Duck Debugger

    Hey Willem ,

    You can filter the html that is produced for the e-mails with a mu-plugin like so:

    How to install:
    Always make sure to keep a backup of your site before changing/adding custom code.

    1] Navigate to your /wp-content/ directory and create a new one named mu-plugins if it doesn't exist.
    2] Inside the mu-plugins folder create a file named frmt-custom-mail-html.php
    3] Edit the file and copy / paste this code snippet inside.

    <?php
    
    add_filter(
    	'forminator_get_formatted_form_entry',
    	function( $html, $custom_form, $data, $entry, $ignored_field_types ) {
    
    		$items     = explode( '</li>', $html );
    		$new_items = array();
    
    		error_log( print_r( $items, true ) );
    
    		foreach ( $items as $idx => $item ) {
    			preg_match( '/(<a href=\')(.*)(\' target=\'_blank\' rel=\'noreferrer\' title=\'View File\'>)(.*)(<\/a>)/', $item, $image_link );
    
    			array_push( $new_items, $item );
    
    			if ( ! empty( $image_link ) ) {
    				$image = '<br/><img src="' . $image_link[2] . '" />';
    				array_push( $new_items, $image );
    			}
    		}
    
    		error_log( print_r( $new_items, true ) );
    		$html_new = join( '</li>', $new_items );
    
    		return $html_new;
    	},
    	15,
    	5
    );

    4] Save and close the file.
    5] The final path should look like /wp-content/mu-plugins/frmt-custom-mail-html.php
    6] Everything should work after that automatically.

    As an example the above code will add an <img> tag right after the Uploaded file as well so the image will be included as well in the message content like this:

    Tell me if you need any further help with this!

    Regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.