I have created a basic multi step form using HTML, CSS and JS. Now all its needs to be added to Wordpress.

Form functionality is : When a user submits the form, send code to their email and ask for the code. If code is ok, then accept submission to DB and send another email with download link for XYZ document.

I am new to Wordpress development, can you please tell me how can I achieve this functionality without any plugin?

  • 2
    Why without a plugin? Doing this would require writing a plugin anyway. May 3, 2023 at 20:15
  • Ohh! I was thinking that without plugin would be possible. Anyways, can you tell me how to write the plugin? Or any guideline because I legit have no clue how to do it in wordpress
    – Frankie
    May 3, 2023 at 20:25
  • Here's the developer docs on writing a plugin.
    – Pat J
    May 3, 2023 at 22:47

2 Answers 2


I will show you the option if you know about the handler functions in php then you can follow the following sequence:

1. Create a function to check the form submission request, after checking the code from the form form successfully, the function will send mail to the user.

2. The function sends mail to the user via smtp to process sending mail right after the successful form check.

3. The function saves the data you want to the database after checking the form.

You can create these steps through a form action in php, or create a function to use ajax. In addition to saving data to the DB, you can use functions in php or if using pure wordpress, you can use $wpdb->insert



To add email code authentication on form submission without using a WordPress plugin, you can use PHP to handle the server-side logic. Here's a step-by-step process on how to achieve this.

  1. First, create a PHP file (e.g., form_handler.php) in your WordPress theme folder to handle form submissions.

  2. In your form's HTML code, update the form action attribute to point to the form_handler.php file you created.

  3. In form_handler.php, start by handling the form data submission and generating a random code.

  4. Next, send the code to the user's email using the wp_mail() function.

  5. You need to create an HTML form to ask the user to input the received code.

  6. In form_handler.php, compare the user's input code with the one stored in the session.

After verifying the input code, you can save the form data to the database and send another email containing the download link for the XYZ document.

Please note that this is a very basic step-by-step example and does not cover security measures like input validation, escaping, and sanitization. Make sure to apply proper security practices when working with user inputs and emails in your project.

  • So you're posting the form to a separate not-part-of-WordPress file? I don't think that's the WordPress way of doing this.
    – Rup
    May 4, 2023 at 13:57
  • (also this reads a bit ChatGPT, but I might be wrong)
    – Rup
    May 4, 2023 at 13:58
  • @Rup the question was asking about how to add authentication without using any plugin. And also I assumed that their form was created via the theme they're using. So I suggested creating a new file "inside" the theme folder. It's inside the theme folder so it would still be part of WordPress or the theme files aren't part of WordPress anymore? May 6, 2023 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.