Proper way to load_template after admin_post.php processing?
-
Hi,
I have an “admin_post_myaction” hook that processed a request, but instead of using wp_redirect() at the end, I would like to simply load a template under the same request. I tried the following and it seems to work but it resulted some PHP Notice message in the debug.log:
// my admin_post_myaction code …
load_template(locate_template(‘page-mytemplate.php’));The debug.log output:
[15-Nov-2021 15:50:55 UTC] PHP Notice: Trying to get property ‘base’ of non-object in /app/wordpress/wp-includes/admin-bar.php on line 765
So my quesiton is, what’s the proper way to load template in the admin-post.php processing workflow?
BTW: One use case of this is I want to process a form using admin-post.php and if it contains error, I want to re-display the form without a full redirect request. If you have another better suggestion to do this, please do share.
Thanks!
- The topic ‘Proper way to load_template after admin_post.php processing?’ is closed to new replies.