• Resolved Orangr

    (@orangr-ghost)


    First – thank you for my new favourite form builder!

    Is there a way so that only the response to a question can be emailed?

    There’s flexibility in that you can add in certain fields with this short code {all_fields} but we only need the responses rather than the full question / label as well.

    Is this possible?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @orangr-ghost

    I hope you are doing well.

    I am happy to hear you like the plugin.

    It is not possible out of the box but I pinged our developers to verify if we have any available hook for that.

    We will keep you posted.
    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @orangr-ghost

    Can you please test the following code:

    <?php
    
    add_filter( 'forminator_custom_form_mail_admin_message', 'wpmudev_remove_labels_from_mail', 10, 5 );
    function wpmudev_remove_labels_from_mail( $message, $custom_form, $data, $entry, $cls_mail ) {
    	if ( 2960 !== intval( $custom_form->id ) ) { // Please change the form ID.
    		return $message;
    	}
    
    	$message = preg_replace("/<b>(.+?)<\/b>/is", '', $message);
    
    	return $message;
    }

    Add it as a mu-plugin: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins and edit the 2960 by adding your form ID.

    Let us know the result you got.
    Best Regards
    Patrick Freitas

    Thread Starter Orangr

    (@orangr-ghost)

    Hi Patrick,

    Thanks for this super-speedy reply!

    It’s nearly perfect. I’ve got it working with out form except that the HTML fields we used for instructions are still appearing in the email. It strips out the label, but keeps the content.

    If possible can our instructions be stripped out as well? Would it be an easy fix to add a CSS class to the fields to ignore? I’m sure your developers may have an even more elegant solution.

    I did try to figure this out before replying.

    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @orangr-ghost,

    Could you please try replacing the previous snippet with this one:

    <?php
    
    $form_id = 2960;
    
    add_filter( 'forminator_custom_form_mail_admin_message', 'wpmudev_remove_labels_from_mail', 10, 5 );
    function wpmudev_remove_labels_from_mail( $message, $custom_form, $data, $entry, $cls_mail ) {
        global $form_id;
    	if ( $form_id !== intval( $custom_form->id ) ) { // Please change the form ID.
    		return $message;
    	}
    
    	$message = preg_replace("/<b>(.+?)<\/b>/is", '', $message);
    
    	return $message;
    }
    
    add_filter( 'forminator_custom_form_mail_admin_message', 'wpmudev_remove_html_field_content_from_mail', 10, 5 );
    function wpmudev_remove_html_field_content_from_mail( $message, $custom_form, $data, $entry, $cls ) {
        global $form_id;
        if ( $form_id !== intval( $custom_form->id ) ) { // Please change the form ID.
            return $message;
        }
    
        $html_data      = array();
        $fields = $custom_form->get_fields();
    
        foreach ( $fields as $field ) {
            if ( false !== strpos( $field->slug, 'html-' ) ) {
                $html_data[] = forminator_get_field_from_form_entry( $field->slug, $custom_form, $entry, false );
            }
        }
    
        foreach ( $html_data as $html_key => $html_val ) {
            if ( $html_val !== '' ) {
                $replace_val = $html_val;
                $message = str_replace( $replace_val, '', $message );
            }
        }
    
        return $message;
    }

    – replace 2960 with your form ID on this line:
    $form_id = 2960;

    I hope this helps. Please let us know if you need any further assistance!

    Best Regards,
    Dmytro

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @orangr-ghost

    We didn’t hear back from you for quite some time so I’m marking it as resolved for now.

    However, if you still need assistance or have any additional questions, just let us know and we’ll get back to you.

    Best regards,
    Adam

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Form email submissions notification content’ is closed to new replies.