I am writing a simple plugin to accept a user number, show a form with information about the user, then post a payment amount. The user number is obtained from this http file include_once(PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php'); and loads perfectly. The info form is filled out using the php file include_once(PLCOA_ADMIN_PATH . 'views/plcoa-payment-add.php'); It has only one field - the payment amount in the form. When the Submit Button is pressed it runs this function.
function payment_post(){
if ($_POST['post_action'] == 'Post')
{
//I do my db INSERT here
}
wp_redirect (PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php');
exit;
}
I've spent hours trying to figure out what I have wrong and I know it's simple. This is all running in the admin area. If I re_direct to an external site it works just fine. Is there some other way to re-direct, after inserting the record in the db, back to the start form?
Thanks in advance!
I am writing a simple plugin to accept a user number, show a form with information about the user, then post a payment amount. The user number is obtained from this http file include_once(PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php'); and loads perfectly. The info form is filled out using the php file include_once(PLCOA_ADMIN_PATH . 'views/plcoa-payment-add.php'); It has only one field - the payment amount in the form. When the Submit Button is pressed it runs this function.
function payment_post(){
if ($_POST['post_action'] == 'Post')
{
//I do my db INSERT here
}
wp_redirect (PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php');
exit;
}
I've spent hours trying to figure out what I have wrong and I know it's simple. This is all running in the admin area. If I re_direct to an external site it works just fine. Is there some other way to re-direct, after inserting the record in the db, back to the start form?
Thanks in advance!
I think you understand wp_redirect
incorrectly.
This function redirects you to a different URL. It’s like sending header('Location: ...');
On the other hand, it looks like you’re trying to pass local path as its param. So it won’t work - such path is not a valid URL address.
Please pay attention to @KrzysiekDróżdż answer.
wp_redirect (PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php');
should be either something like
wp_redirect (PLCOA_ADMIN_URL . 'views/plcoa-payment-start.php');
// Assuming PLCOA_ADMIN_URL is defined
OR
include_once (PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php'); // Recommended