• I have a script that when the user clicks submit on the form, it processes the options selected by the user and generates an html that is I want to send in the notification email.

    I have tried adding an HTML field to the form and changing the internal html through the script with something like:

    let previewField = form.querySelector('#html-x .forminator-field');

    if (previewField) {
    previewField.innerHTML = <div>${previewHTML}</div>;
    }

    Then in the form’s notification configuration I specify that the email contains only the {html-x} field but the email continues to be sent without the changes that the script made to the field.

    I also tried with an input field normally and previewField.value = previewHTML worked but the problem is that everything is saved as plain text and the html tags do not work.

    What solution can you recommend, what hooks do you think could help me get what I need?

    I Have Forminator V1.35.0

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @barceloch

    I hope you are doing well today.

    I think the script itself makes things more complex here and if I understand your mail goal correctly you can achieve this with default Forminator features.

    In the first place, you have some dropdown field and a couple of items there. Based on the item selected from that dropdown you want to show different previews, so in short different HTML fields.

    To accomplish this simply make multiple HTML fields and set up conditional logic for each HTML field to show only when a specific item from the dropdown is selected.

    Later on, create multiple email notifications with the same conditional logic, so that different types of email (different email bodies) will be sent only when that item from the dropdown is selected.

    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#Forminator-Conditional-Logic
    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#conditions-tab

    Kind Regards,
    Kris

    Thread Starter barceloch

    (@barceloch)

    Thank @wpmudevsupport13, my form is something like this:

    name:
    mail:
    address:

    OPTION 1 title: (section field)
    OPTION 1: (group field)
    [
    Option name (checkbox-1)
    Option data 1 (html field)
    Option data 2 (html field)
    Option select (select field)
    ]

    OPTION 2 title: (section field)
    OPTION 2: (group field)
    [
    Option name (checkbox-2)
    Option data 1 (html field)
    Option data 2 (html field)
    Option select (select field)
    ]

    OPTION 3 title: (section field)
    OPTION 3: (group field)
    [
    Option name (checkbox-3)
    Option data 1 (html field)
    Option data 2 (html field)
    Option select (select field)
    ]



    Then the script processes the form data and creates a result html, with the fields name, email, address and includes only the sections and information of the Groups Field where the checkbox is selected.

    I want send that html result in the email notification.

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @barceloch,

    We would recommend using the inbuilt settings in the form ie Conditions as mentioned before for such a workflow.

    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#Forminator-Conditional-Logic
    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#conditions-tab

    If you are looking for hooks for your snippet, you can refer to these hooks and see if that helps:
    forminator_custom_form_mail_before_send_mail under forminator/library/modules/custom-forms/front/front-mail.php and send_email?function under /forminator/library/modules/custom-forms/front/front-action.php

    However, if you are looking for a custom snippet then I’m afraid this will be outside the scope of support we can provide.

    For that, you’ll need to hire a developer to provide the required custom code for you. WordPress provides a jobs directory here https://jobs.wordpress.net, if you need further advice about it, feel free to email [email protected].

    Subject: ATTN: WPMU DEV support – wp.org”

    Kind Regards,

    Nithin

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