LeadOnForm – Salesforce Integration

By sanplugin

0+ active installationsVersion 1.3.4

Connect WordPress forms to Salesforce Leads. Supports native HTML forms, Contact Form 7, and Ninja Forms, with field mapping through CSS classes.

Description

LeadOnForm connects selected WordPress form submissions to Salesforce Leads through a server-side API integration. Configure Salesforce credentials in the WordPress admin, choose Sandbox or Production, test the connection, and map form fields using their Salesforce API names.

The plugin supports:

  • Native HTML forms: detects a form submission and sends the mapped fields to Salesforce without cancelling or replacing the form’s normal submission.
  • Contact Form 7: sends data after Contact Form 7 confirms a successful submission (wpcf7mailsent).
  • Ninja Forms: sends data after Ninja Forms returns its successful AJAX response (nfFormSubmitResponse).
  • Other custom integrations: exposes a JavaScript method and a custom success event for integrations that can confirm successful submission.

Main features:

  • Separate Sandbox and Production credentials and environment selection.
  • Connection test for each configured environment.
  • Field mapping with sf- CSS classes; HTML field names can remain unchanged.
  • Create a new Lead or update an existing unconverted Lead when a matching email is found.
  • Salesforce response codes and messages are recorded in the event log, including validation errors returned by Salesforce.
  • Honeypot and IP-based rate limiting for the public endpoint.
  • Bounded event log with masked email addresses and no full form payload or Salesforce credentials.
  • Extension hooks for successful and failed submissions.

Important: LeadOnForm does not replace the form plugin’s own validation or submission process. If the original form prevents submission, LeadOnForm does not send a Lead. Salesforce validates the data it receives; Salesforce validation errors are recorded in the LeadOnForm log.

Salesforce is a trademark of Salesforce, Inc. LeadOnForm is an independent project and is not affiliated with or endorsed by Salesforce, Inc.

Configuration screenshots

The Configuration screen stores separate Sandbox and Production connection settings. The Consumer Secret is not displayed after it has been saved. The example screenshot has sensitive values hidden.

Quick start: how field mapping works

Two things are required for each form:

  1. An opt-in hidden field with the exact name and value below:

  2. A CSS class on each field that should be sent to Salesforce. The class must start with sf-, followed by the exact Salesforce Lead field API name.

For example:

<input type="text" name="your_first_name" class="sf-FirstName">

This sends the value to Salesforce FirstName. The HTML name attribute remains your_first_name and does not need to match the Salesforce API name.

Common field classes:

  • sf-FirstName — First name.
  • sf-LastName — Last name.
  • sf-Company — Company.
  • sf-Email — Email address.
  • sf-Phone — Phone.
  • sf-MobilePhone — Mobile phone.
  • sf-Title — Job title.
  • sf-Website — Website.
  • sf-Description — Description.

Use the exact API name of a supported Lead field in your Salesforce organization. Salesforce permissions, required fields, validation rules, and customizations still apply.

Native HTML form example

Add the hidden field and the sf- classes to your existing HTML form. You do not need to add a special class to the <form> element.

<form id="contact-form" method="post" action="/process-contact/">

  <label>First name
    <input type="text" name="first_name" class="sf-FirstName">
  </label>

  <label>Last name
    <input type="text" name="last_name" class="sf-LastName">
  </label>

  <label>Company
    <input type="text" name="company" class="sf-Company">
  </label>

  <label>Email
    <input type="email" name="email" class="sf-Email">
  </label>

  <label>Mobile
    <input type="tel" name="mobile" class="sf-MobilePhone">
  </label>

  <input type="hidden" name="salesforce_lead" value="1">
  <button type="submit">Send</button>
</form>

LeadOnForm listens for the native form submit event and sends the mapped values independently. It does not call preventDefault(), change the form action, or replace the original form submission. Browser validation such as required and type="email" remains under the browser’s control. If the browser or another script prevents the form from submitting, the native integration does not send a Lead.

Contact Form 7 example

Contact Form 7 is supported automatically. Edit the form in Contact Form 7 and add the hidden field and CSS classes to the relevant form-tags:

[hidden salesforce_lead "1"]

[text first_name class:sf-FirstName]

[text last_name class:sf-LastName]

[text company class:sf-Company]

[email email class:sf-Email]

[tel mobile class:sf-MobilePhone]

[submit "Send"]

LeadOnForm waits for Contact Form 7’s wpcf7mailsent event. Therefore, the Salesforce request is made only after Contact Form 7 reports a successful submission; a Contact Form 7 validation failure does not trigger the integration.

Ninja Forms example

Ninja Forms is supported automatically. In the Ninja Forms builder:

  1. Add the fields needed for your Lead, such as First Name, Last Name, Company, Email, and Mobile.
  2. Edit each field and open its Advanced settings.
  3. In the field’s CSS Classes setting, add the matching Salesforce class, for example sf-FirstName, sf-LastName, sf-Company, or sf-Email.
  4. Add a Hidden field. Set its field key/name to salesforce_lead and its default value to 1.
  5. Save the form and submit a test entry.

Ninja Forms returns submitted field values in its AJAX response. LeadOnForm reads those values, matches them to the form fields and their sf- classes, and sends the Lead after the nfFormSubmitResponse event. It does not depend on the form values still being present in the browser after Ninja Forms has processed the submission.

Other plugins and custom integrations

For a form plugin not listed above, use the documented successful-submission callback provided by that plugin. Call LeadOnForm only after the plugin confirms that its own submission and server-side validation succeeded.

JavaScript method:

LeadOnForm.send(formElement);

Example for a plugin’s success callback:

const form = document.querySelector('#my-form');
if (form) {
    LeadOnForm.send(form);
}

Alternatively, dispatch the custom success event after the form plugin confirms success:

form.dispatchEvent(new CustomEvent('leadonform:form-success', { bubbles: true }));

The form must contain the salesforce_lead=1 hidden field and the mapped sf- classes. Do not call this method on the initial submit event when the form plugin may still reject the submission on its server.

How Salesforce creates or updates a Lead

When LeadOnForm receives a form submission, it sends the mapped values to the Salesforce API configured by the administrator.

  • If an unconverted Lead with the same email address is found, LeadOnForm updates that Lead.
  • If no matching unconverted Lead is found, LeadOnForm creates a new Lead.
  • Salesforce applies its own required-field rules, field limits, permissions, and validation rules. LeadOnForm records the response returned by Salesforce.

Examples of outcomes:

  • HTTP 201: Salesforce successfully created a Lead.
  • HTTP 200: Salesforce successfully updated a Lead.
  • HTTP 400 with REQUIRED_FIELD_MISSING: Salesforce rejected the request because a required field, such as LastName, was missing.
  • HTTP 400 with STRING_TOO_LONG: Salesforce rejected a value that exceeded the field’s configured maximum length.

These are examples; the exact response depends on the Salesforce organization and its validation rules.

Event log

Open LeadOnForm > Logs in the WordPress admin to review recent requests. The log includes the date, environment, request ID, status, operation, masked email, form path, Salesforce Lead ID when available, HTTP status, and response detail.

The plugin retains a maximum of 200 recent events. Email addresses are masked. Full form values, OAuth tokens, and client secrets are not stored in the event log.

Troubleshooting

No Lead appears in Salesforce

  • Confirm the form contains salesforce_lead=1.
  • Confirm each mapped field has the correct sf- class and Salesforce API field name.
  • Confirm the selected Salesforce environment and credentials are correct.
  • Open LeadOnForm > Logs and review the HTTP status and response detail.
  • Confirm the Salesforce integration user has permission to create or update Leads and access the mapped fields.

A Salesforce validation error appears in the log

This means the request reached Salesforce and Salesforce rejected the data. Review the error code and message in the Detail column, then check the corresponding Salesforce field requirement, maximum length, validation rule, or permission.

A form plugin reports a validation error

LeadOnForm should only run after the form plugin confirms success. Contact Form 7 and Ninja Forms have dedicated success-event integrations. For other plugins, use their documented successful-submission callback. The original form’s own validation and submission behavior is not replaced by LeadOnForm.

The connection test fails

Check the selected environment, Connected App credentials, Login URL, Salesforce API access, integration-user permissions, and outbound HTTPS connectivity from the WordPress server.

Extension hooks

LeadOnForm provides these actions for optional extensions:

  • leadonform_submission_completed — receives an associative array after a successful Lead create or update.
  • leadonform_submission_failed — receives an associative array after a submission error.

The event payload can include request_id, environment, status, operation, http_status, salesforce_id (on success), error_code (on failure), route, and occurred_at. It does not include the full submitted form payload, full email addresses, OAuth tokens, or client secrets.

Privacy

LeadOnForm sends selected form fields to the Salesforce instance configured by the site administrator. The plugin stores its configuration and a bounded event log in the WordPress database. Email addresses in the log are masked, and the complete submitted form payload is not stored. Site administrators are responsible for providing appropriate privacy notices, obtaining any required consent, and complying with applicable data-protection and retention requirements.

Installation

  1. In WordPress, go to Plugins > Add New Plugin > Upload Plugin.
  2. Upload the LeadOnForm ZIP file and select Install Now.
  3. Activate LeadOnForm.
  4. Open LeadOnForm in the WordPress administration menu.
  5. Select the active environment: Sandbox or Production.
  6. Enter the Salesforce Connected App Consumer Key, Consumer Secret, and Login URL for that environment. Save the settings.
  7. Use the corresponding Test connection button and confirm that the connection succeeds.
  8. Add the opt-in field and Salesforce field classes to the forms that should send Leads.
  9. Test submissions in Sandbox before switching to Production.

Screenshots

Changelog

1.3.4

  • Added automatic integration for Ninja Forms after its successful AJAX response.
  • Kept native HTML form submission independent from the Salesforce request; LeadOnForm does not cancel the original form submission.
  • Let Salesforce validate required Lead fields and record the Salesforce REST error code and message in the event log.
  • Standardized opt-in detection on salesforce_lead=1 and field mapping on sf- classes.
  • Added automatic Contact Form 7 integration after its successful-submission event.
  • Added the LeadOnForm.send(formElement) API and a generic success event for custom integrations.
  • Improved checkbox and radio field handling.
  • Expanded documentation for native HTML, Contact Form 7, Ninja Forms, field mapping, and troubleshooting.

1.3.3

  • Format the authentication HTTP status in the exception message for static-analysis compatibility.
  • Clarified that sanitized redirect status/message query parameters are display-only and do not change state.

1.3.2

  • Normalized HTTP response status codes before use in error handling.
  • Added explicit static-analysis annotations for admin request values that are nonce-verified or display-only.
  • Updated the Tested up to header to 7.1; validate compatibility on that WordPress version before release.

1.3.1

  • Removed raw Salesforce response bodies from exception messages.
  • Improved IP address sanitization for rate limiting.
  • Removed development error logging from normal plugin execution.
  • Added the required Tested up to readme header.
  • Documented nonce handling for the WordPress Settings API sanitizer.

1.3.0

  • Renamed the public-facing plugin to LeadOnForm.
  • Added documented success and failure hooks for future extensions.
  • Added readme documentation and GPL license metadata.

1.2.1

  • Added honeypot and IP-based request limiting.