skip to Main Content

I am trying to accomplish something seemingly simple.

I would like to create a WordPress form field in which a user can enter an alphanumerical text. So far so good.

The challenge: This entry should be appended to the URL which is called when clicking the Submit button.

For example:

User enters: LookBlueElephants
On submit the user gets directed to http://www.example.com/LookBlueElephants

I am using the DIVI Builder and see that there is an option to enter the Redirect-URL in the form. Yet I do not know how to get it to be dynamic, based on the user input.

Thank you for your assistance. 🙂

2

Answers


  1. Chosen as BEST ANSWER

    Alright. After much tinkering, here the solution I took.

    Created a form with Contact Form 7 and added Redirection for Contact Form 7 Plugin. With a plugin that allows inserting PHP code (for example Insert PHP Code Snippet) I added a simple redirect:

    header('Location: http://www.example.com/' . $_GET['your-variable']);
    exit;
    

    Just make sure that under Redirect Settings (in the Contact Form 7 settings) the box "Pass all the fields from the form as URL query parameters" is ticked.

    Then create a new page where you insert the above code snippet (how that is done may depend on which plugin you use). Now enter the URL to that page into the Contact Form settings (Redirect Settings) and you're done.

    The form will send the content of the form to the new page, the new page will take the GET variables and redirect to wherever you want.

    Hope this will be of use to someone.


  2. That’s exactly what I was looking for, thank you so much for your input.
    After finding your solution, I tried a workaround using Elementor Pro Form that has after submit actions.

    • Give an ID to your Field on the advanced tab.
    • Copy the shortcode generated, looks like this : [field id="example"]
    • On the actions after submit option, select Redirect.
    • Redirect menu should appear, Choose redirect to shortcode and paste the shortcode we generated
    • On the advanced options of the shortcode redirection, put a before value (your domain).
      Save changes.

    It then generates a link after submit like : wwww.yourdomain.com/whatever-you-wrote-on-field

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search