Form using admin-post.php gives 404 after submission

First of all… Your action is called rguroo_email_verification_form, so you should use it when registering your hooks. But you use this instead: add_action( ‘admin_post_nopriv_email_verification_form’, ‘verify_and_sanitize_email_form’, $priority = 10, $accepted_args = 1 ); add_action( ‘admin_post_email_verification_form’, ‘verify_and_sanitize_email_form’, $priority = 10, $accepted_args = 1 ); It should be: add_action( ‘admin_post_nopriv_rguroo_email_verification_form’, ‘verify_and_sanitize_email_form’, $priority = 10, $accepted_args = 1 ); … Read more

Stop SPAM from custom form

I’ve been studying (and blocking) automated form spam for years. Most advice relates to hidden fields, CSS tricks, ‘stupid’ questions (“what is 1+3”), and others. And the reason that those tricks (and others) don’t work with automated spam bots is that they don’t ‘see’ your form, they just post to it. They scrape the form, … Read more

Capture form data in one function and use it in another function (same file)

You could use WordPress Transients to temporarily set a variable in the WP database with one function, and get that variable with another function. function setPrice(){ $myPrice = $_POST[‘price’]; set_transient( ‘ex1_temp_price’, $myPrice, 28800 ); // Site Transient } // this function can be kicked off the shortcoe, within the transient timeout function use_price(){ $price = … Read more

Form Submission Not Working In Custom Theme

WordPress uses Name, email post fields to do post comments, If you renamed the your form elements name attributes to be f-name and f-email then your issue will be resolved. I have made changes in below code and it is working now. <?php if($_POST[‘f-submit’]) { if(!$_POST[‘f-name’]) { $error=”<br>- Please enter your name”; } if(!$_POST[‘f-email’]) { … Read more