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');


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!

2 Answers 2


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.

  • Many thanks. I did misunderstand. I should have picked up on that when I went to an external site. What is the best way to back to my beginning page? The page I want to get to is on my admin_menu.
    – Bud
    Commented Feb 25, 2019 at 19:26

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


include_once (PLCOA_ADMIN_PATH . 'views/plcoa-payment-start.php'); // Recommended
  • Your second suggestion worked - except that I dropped out of the admin wrapped area. All I have is a white screen with the form that I want. From there if I enter a user number I do get back in the admin wrapper with the correct form.
    – Bud
    Commented Feb 25, 2019 at 19:46
  • I guessed from your question that your code uses include_once() for different tasks on main admin page. I hope you will now adjust your code using some if... else decisions to fit your needs. Commented Feb 25, 2019 at 19:57
  • Thank you. I'll haven't used include_once() before so I'll look into it.
    – Bud
    Commented Feb 25, 2019 at 20:44
  • I don't know what I was thinking. I have used include_once. My problem now is that my form looks like it was created using straight php code. All of the wp admin header and side bars are gone. Could that we cause by the content of my html? It does work from the admin_menu.
    – Bud
    Commented Feb 25, 2019 at 21:21
  • Based on last line of your comment on @Krzysiek Dróżdż answer, it is suggested that you should use wp_redirect ( menu_page_url( 'your_menu_slug') ); where your_menu_slug should be replaced with the slug with which your admin page is registered. Commented Feb 26, 2019 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.