Skip Navigation

[Escalated to 2nd Tier] Toolset forms adding tags even if noautop is used in notifications

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 6 replies, has 1 voice.

Last updated by Christopher Amirian 1 day, 17 hours ago.

Assisted by: Christopher Amirian.

Author
Posts
#2847552

I am trying to:
Send Toolset Forms notifications styled with beefree (basically just a cross-client compatible HTML styled email)

I expected to see:
Actually styled emails

Instead, I got:
Tons of

<p>

tags added
If using

[wpv-noautop]

to wrap whole email, tons of

< br/>

tags added where html has line breaks
If minified and using

[wpv-noautop]

, still adding

<p>

tags in the send email for example like

<![endif]--><style>*

becomes

<![endif]--></p><style>*

(without ever an opening p tag, and anyway, it should not inject random things)

In summary: you cannot send proper client compatible emails.

#2847644

Christopher Amirian
Supporter

Languages: English (English )

Hello,

Welcome to Toolset support. We certainly will not be able to support all email clients, but I will be happy to check how you set the notification to test.

I created a clean installation of Toolset, and you can enter the admin here:

hidden link

I created a form, and you can add a notification there:

hidden link

Please add the simplest notification code that you can, which will show the issue, and I will test it on various email clients.

Thanks.

#2847852

I have added a notification to said form - in the unminified and unconcatenated version.
You can ask GPT to prep if for Toolset forms because it is the only tool wide and far that was able to concatenate and minify it in a way without breaking it - however, you will see that it still adds those unexpected tags, thus breaking rendering on the client side.

You do not necessarily need to send yourself an email - you can just use a mail logger WP side and look at the HTML preview for example.

Note, Toolset Forms does not (and cannot) "support all mail clients". This is why we have a notification HTML editor were we can add support for it.

Also note, this issue has been reported in past but all tickets I found have been deleted, see for example:
https://toolset.com/forums/topic/rogue-paragraphs-being-inserted-into-toolset-form/

I thought I even had reported this myself once but couldn't find the ticket anymore, so probably I imagined it.

#2848238

Christopher Amirian
Supporter

Languages: English (English )

Hello and thank you for the code.

I asked the second tier support to take a look and I will get back to you as soon as I have an update.

Thanks.

#2848501

Christopher Amirian
Supporter

Languages: English (English )

Hello,

The issue is escalated to the development team. The issue is that the shortcode (wpautop) is applied to the whole message, including the body, instead of the inner HTML.

Please add the code below to either your theme functions.php or use the Toolset custom code section from settings:

remove_filter( 'toolset_the_content_basic_formatting', 'wpautop', 10 );

That should fix the issue. The scope for this filter removal is global. You might need to apply it per case if you need.

After you apply the fix please use the RAW button to avoid haing P tags and the BR tags will not be added to the message.

Thanks.

#2850221

This does seem to resolve the issue.

I hooked it to CRED with

add_action( 'cred_submit_complete', 'my_toolset_disable_autop_for_notifications', 10, 2 );

function my_toolset_disable_autop_for_notifications( $post_id, $form_data ) {
    // Optional: limit to a specific form ID
    // if ( (int) $form_data['id'] !== 123 ) {
    //     return;
    // }

    // Disable auto paragraphs in Toolset's basic formatting for this request
    remove_filter( 'toolset_the_content_basic_formatting', 'wpautop', 10 );
}

Any better ideas?

In any case do you mind to keep this open as escalated afterwards?
Thanks!

#2850222

Christopher Amirian
Supporter

Languages: English (English )

Hello,

Thank you. Yes I will set the ticket as escalated.

Thanks.