How to Add Free Email OTP Verification in Elementor Form Without Any Extra Plugin
In today’s blog, we will learn how to add Email OTP Verification to Elementor forms — completely free, without using any third-party plugin or external service. All it takes is a bit of custom code and smart use of Elementor’s built-in features.
Let’s get started.
Step 1: Add the PHP Code to Your Site
First, copy the PHP code provided in this blog and place it inside your WordPress theme (preferably in the functions.php file of your child theme) or insert it using a plugin like “Code Snippets”.
This code will handle OTP generation and email sending logic.
Step 2: Create Two Pages with Elementor Forms
Now, create two separate pages. Each page will have its own Elementor form.
Page 1 – User Information + Hidden Field
Add a form where you collect user details (e.g., name, email).
Add a hidden field.
Set a default value using the Dynamic Tags option.
From there, choose Shortcode, and paste the shortcode provided in this blog.
Enable Redirect After Submit, and set the redirection to your second page’s URL.
Pass all form data as URL parameters to the second page.
Turn on the Email 2 option, and in the To field, insert the shortcode of the user’s email field.
In the email content, only include the hidden field value (which is the OTP code).
Step 3: Create the Second Page – OTP Verification Form
On the second page:
Add a form with fields matching the values passed as GET parameters.
Use dynamic content or shortcode to populate each field using the
$_GETvalues.Add a hidden field with the ID:
VerificationCodeand set its value using the OTP sent earlier.Add another input field where the user will enter the code they received in their email.
Set this field’s ID to:
VerificationCode_check
Finally, set the submit button’s ID as
ele-form-button.
With this setup, your Elementor Email OTP Verification system is complete.
Bonus: Watch the Step-by-Step Video Tutorial
To understand the full process more clearly, watch our attached video tutorial where we explain each step visually.
Verification input Field 1 ID:
VerificationCode
Verification input Field 2 ID:
VerificationCode_check
Form-2 Submit button ID
ele-form-button
PHP
generate_random_id_shortcode() {
$random_id = mt_rand(1000, 9999);
return "PW".$random_id;
}
add_shortcode('random_id', 'generate_random_id_shortcode');
shortcut
Code Verification javascript
// Function to setup validation for a form
function setupFormValidation(formElement) { var emailField = formElement.querySelector('#form-field-VerificationCode'); var emailCheckField = formElement.querySelector('#form-field-VerificationCode_check'); var htmlField = formElement.querySelector('.elementor-field-type-html'); var submitButton = formElement.querySelector('#ele-form-button'); if (emailField && emailCheckField && htmlField && submitButton) { function validateEmails() { if (emailField.value === emailCheckField.value) { htmlField.innerHTML = "Your code is match successful"; submitButton.disabled = false; } else { htmlField.innerHTML = "Your code is incorrect"; submitButton.disabled = true; } } emailField.addEventListener('input', validateEmails); emailCheckField.addEventListener('input', validateEmails); submitButton.disabled = true; } }
// Apply to all forms
var allForms = document.querySelectorAll('form');
// or more specific like: .elementor-form
allForms.forEach(function (form) { setupFormValidation(form); }); }); </script>




