managed wordpress hosting

Custom Contact Form in WordPress


On 08-17-2013 code, wordpress

Your own custom Contact Form in WordPress.

There are tons of contact form plugins. For a while I was using Contact Form 7, but after a few plugin updates, I was starting to get feedback the form was giving problems. Always spitting out an error that the form couldn’t be submitted. So I decided that I wanted a custom form that I would build out in Raw PHP, and just have a template page with my custom PHP code.

First problem I was running into was 404 error.
I found on a couple forums, that a variable or field with the word “name” is already taken by WordPress so you can not use it, my solution, change that variable to “clientname”.

Also there were a couple other things I needed to change.

mail();
wp-mail();
header('Location: http://www.yourdomain/thank-you');
wp-redirect('http://www.yourdomain/thank-you');

These small changes fixed any errors or broken code. There are so other implementations for forms, such as uploads, WordPress has a function for that as well. I will add more as time goes on.