$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - wp_redirect doen't work|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - wp_redirect doen't work

matteradmin9PV0评论

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!

Share Improve this question asked Feb 25, 2019 at 18:51 BudBud 438 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

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

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far