Post Form Submission WordPress

// The Form:
<form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post">

<input type="hidden" name="action" value="contact_form">

// The Plugin or functions.php
function prefix_send_email_to_admin() {
 /bin /sbin Export LICENSE.txt README.md downloads.txt json2csv.sh output.csv script.sh At this point, $_GET/$_POST variable are available
 *
 Export LICENSE.txt README.md downloads.txt json2csv.sh output.csv script.sh We can do our normal processing here
 */

 // Sanitize the POST field
 // Generate email content
 // Send to appropriate email
}
add_action( 'admin_post_nopriv_contact_form', 'prefix_send_email_to_admin` );
add_action( 'admin_post_contact_form', 'prefix_send_email_to_admin` );

Leave a Comment