WP Forms Stopped Working With NitroPack
Updated over a week ago

WP Forms is a WordPress plugin for creating and adding forms to your website. However, sometimes the form stops working when additional caching like NitroPack is active on your website.


Why did my form stop working?

By now, you’re familiar with the most common indicator that something’s not right such as the error:

Form was unable to submit. Please contact the site administrator.

If the page with the contact form is being optimized by NitroPack, the reason it stopped working after a while is the parameter called “data-token”.

It’s used for Anti-spam protection that expires in 48 hours.

When the page is cached, the “data-token” expires, but the cached version contains the old token.


How do I fix it?

⚠️Currently, NitroPack is working on extending its compatibility with the WP Forms plugin to prevent this issue. For now, the following solutions can be used:

1️. Exclude the page containing the form from optimization.

This option works best if you only have a form on a /contact page.

However, we recommend the second solution if the form is on the home page or it is present on multiple pages.

2️. Set an automatic cache purge for the pages containing the forms

By setting an automatic cache purge to be performed every 24 hours, the data token can be properly re-generated. This can be done with WP CLI.

The command itself for WP CLI would be:

wp nitropack purge --purge-url=https://domain.com/page

Then the cron job, for example, once a day at 00:00:

0 0 * * * /path/to/wp-cli/wp --path=/path/to/your/website nitropack purge --purge-url=https://domain.com/page

The paths in the cron job need to be adjusted based on where WP CLI is installed on the server and the path to your website.

Your hosting support can assist with setting this up.

📌 If you need assistance or have questions, reach out to our support team at [email protected] or via this link: https://support.nitropack.io. Our usual response time is 20 minutes.

Did this answer your question?