Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Hope someone can help with a WP problem. Need a page redirect on form submission. Easy right? Old version though..

The site owner asked me to put a form on the font page - ignoring myriad other problems the site has, including software updates, she wants the submit button to a) submit the form and b) take users to another page in the site. Can I do this by adding some code to the PHP file for that page or is there another way I should do it? Im not sure I can edit the code for the button's behavior.

Sean Roberts
Sean Roberts
4,856 Points

Are you unable to use a form plugin? Contact Form 7 can do exactly what you need and can be placed anywhere on the site using the shortcode functionality. That said, pending on your theme you may need to need to place the shortcode in a php template file using the do_shortcode function.

1 Answer

The code for the form is below. In the page editor, its called the "SiteOrigin" contact form. Which I guess is a widget package of some sort? I dont know if I can use contact form 7 on her site, because its so outdated? Im going to try to convince her to let me update it and make the whole site better, but for now, I just really want to make the form do what she wants it to do.
It is WordPress version 3.9.13 running a Helios Child theme.

<form action="/wp-admin/admin-ajax.php?_panelsnonce=36a48dc08d#contact-form-f290" method="POST" class="sow-contact-form" id="contact-form-f290">
<label class="sow-form-field-label-Array" for="sow-contact-form-field-your-name-5777b2342296c"><strong>Your Name</strong></label><br />
<span class="sow-field-container"><input type="text" name="your-name-5777b2342296c" id="sow-contact-form-field-your-name-5777b2342296c" value="" class="sow-text-field"></span><label class="sow-form-field-label-Array" for="sow-contact-form-field-your-email-5777b2342296c"><strong>Your Email</strong></label><br />
<span class="sow-field-container"><input type="email" name="your-email-5777b2342296c" id="sow-contact-form-field-your-email-5777b2342296c" value="" class="sow-text-field"></span><label class="sow-form-field-label-Array" for="sow-contact-form-field-phone-5777b2342296c"><strong>Phone</strong></label><br />
<span class="sow-field-container"><input type="text" name="phone-5777b2342296c" id="sow-contact-form-field-phone-5777b2342296c" value="" class="sow-text-field"></span><label class="sow-form-field-label-Array" for="sow-contact-form-field-jurisdiction-5777b2342296c"><strong>Jurisdiction</strong></label><br />
<span class="sow-field-container"><input type="text" name="jurisdiction-5777b2342296c" id="sow-contact-form-field-jurisdiction-5777b2342296c" value="" class="sow-text-field"></span>       <input type="hidden" name="instance_hash" value="f290e3b481a72cbbe122300ba59492da"><br />
<input type="submit" value="GET FREE DEMO" class="sow-submit"><br />
</form>