Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Dennis Eitner
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dennis Eitner
Full Stack JavaScript Techdegree Graduate 25,644 Points

Order Form in Wordpress (get Post-values)

I have a 3-column order form (name, price, number-input).

<?php the_field( 'name_des_weines' ); ?>
<?php the_field( 'preis' ); ?>
<input type="number" class="form-control col-md-2" maxlength="3" size="4" value=""> 

Question: how do I get the value of the number field and the name of the first filed so I can send it by email to the admin?

Thanks for your help!

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

It's going to basically be like anything else. You're going to need to send that information somewhere, and put those values into variables. Than you could use some library like PHPMailer to use the information stored in those variables to generate and send an email.

They do have lessons here in the PHP section on how to pull information from a form and use PHPMailer to send an email. I believe Randy does this when building Mike's t-shirt shop. It's probably in the advance PHP lessons if memory serves me right.

The other option is to use a plugin that will allow you to do what you want to do. Gravity forms is a paid plugin, but I know it would allow you to do all of this, without having to write any code.