I need to send a form submission to a specific endpoint but before I do that I want to do some custom handling on it. So I set up a custom handling function but now I can't figure out how to get the POST and forward it to the final endpoint.
Here is what I have:
<form class="" action="<?php echo admin_url('admin-post.php') ?>" method="post">
<input type="hidden" name="action" value="bb_submit_email">
<input type="email" id="email" name="email" value="example@email.com" required>
<?php echo wp_nonce_field('submit-email', '_mynonce'); ?>
<input type="submit" class="float-right btn btn-primary form-button" value="Submit">
</form>
add_action('admin_post_bb_submit_email', 'bb_handle_email_submit');
add_action('admin_post_nopriv_bb_submit_email', 'bb_handle_email_submit');
function bb_handle_email_submit() {
$logger = wc_get_logger();
if ( !isset($_POST['_mynonce']) || !wp_verify_nonce($_POST['_mynonce'], 'submit-email')) {
$logger->add('submit-email-debug', 'nonce failed!');
return;
}
When my custom handler is triggered, is there a way to get the post request and forward it to an external endpoint?