Change Divi Contact Form Action URL

|

The Divi Contact Form module lets you create flexible forms for collecting information from your users. Normally, the information collected is delivered to you as an email. But by modifying the URL to which the collected information is sent you could, for example, send the information to an API endpoint of your own creation for custom processing / storage. Here's how to change the "action" URL to which the form information is sent.

Setting the Contact Form URL via JQuery

First, give your contact form a CSS class, such as "custom_action_url", as show:

Then add the following jQuery code to your site, changing the example URL to the URL you want to send the information to:

<script>
jQuery(function($) {
	$('.custom_action_url .et_pb_contact_form').attr('action', 'https://yoursite.com/api');
});
</script>

Your contact from should now send the contact form information to your chosen URL.

Redirecting the User

Normally the Divi contact form will be replaced by a notice information the user that the message has been sent. But this doesn't occur when submitting to a custom URL. One way around this is to use the contact form's "redirect" feature to redirect the user to a custom "success" page after they submit the form.

You can configure the redirect at "Contact Form Settings > Content > Redirect", like so:

This post may contain referral links which may earn a commission for this site

Hundreds of new features for Divi
in one easy-to-use plugin

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *