Skip to content
Lazyform
Docs menu

Frameworks and builders

WordPress

Add a Lazyform contact form to WordPress with a Custom HTML block. No plugin, no SMTP setup, no PHP.

WordPress form plugins send email through your server, which often lands in spam or needs SMTP setup. With Lazyform you paste a plain HTML form into a Custom HTML block and submissions are delivered for you.

Before you start

Get an access key: type your email on the homepage for an instant key, or sign in and create a form. You'll paste it where you see YOUR_ACCESS_KEY (keys start with lf_).

Add the form with the block editor

  1. Edit the page where the form should appear.
  2. Add a block and choose Custom HTML.
  3. Paste the code below and replace YOUR_ACCESS_KEY.
  4. Update the page, then send a test message from the live page.
Custom HTML block
<form action="https://lazyform-api.xvelopers.com/submit" method="POST" class="lazyform">
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">
  <input type="hidden" name="subject" value="New message from my WordPress site">
  <input type="hidden" name="redirect" value="https://example.com/thank-you/">

  <p><label>Name<br><input type="text" name="name" required></label></p>
  <p><label>Email<br><input type="email" name="email" required></label></p>
  <p><label>Message<br><textarea name="message" rows="5" required></textarea></label></p>

  <input type="checkbox" name="botcheck" class="hidden" style="display:none">

  <p><button type="submit">Send</button></p>
</form>

Create a "Thank you" page in WordPress and put its URL in the redirect field, or remove that line to use Lazyform's thank-you page. Your theme's styles apply to the inputs automatically.

Optional: show the message inline

To keep visitors on the page, paste this below the form in the same Custom HTML block:

Custom HTML block (after the form)
<p class="lazyform-status" role="status"></p>
<script>
  document.querySelectorAll('form.lazyform').forEach(function (form) {
    var status = form.nextElementSibling;
    form.addEventListener('submit', async function (event) {
      event.preventDefault();
      status.textContent = 'Sending...';
      try {
        var response = await fetch(form.action, {
          method: 'POST',
          headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
          body: JSON.stringify(Object.fromEntries(new FormData(form))),
        });
        var result = await response.json();
        status.textContent = result.success
          ? 'Thanks! Your message has been sent.'
          : (result.error && result.error.message) || 'Something went wrong.';
        if (result.success) form.reset();
      } catch (e) {
        status.textContent = 'Network error. Please try again.';
      }
    });
  });
</script>

Some WordPress setups strip <script> tags for users without the "unfiltered HTML" permission (common on multisite and some managed hosts). If the script disappears after saving, the form still works with the plain redirect version.

Other ways to add it

  • Classic editor. Switch to the Text tab (not Visual) and paste the form.
  • Theme files. Paste the form into a template file, or add it as a reusable block (pattern) so you can drop it on any page.
  • Page builders. Elementor, Divi and similar builders have an HTML or code widget. Paste the same form there.

Form plugins like Contact Form 7 send to WordPress itself and can't post to Lazyform, so use the HTML form instead of their shortcodes.

Where to go next