最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - Redirect in WordPress plugin

programmeradmin2浏览0评论

I am learning WordPress plugin development. I am trying to redirect user to plugins home page after submitting a Form. My code is like below

wp_redirect(plugin_dir_url(__FILE__)); 
exit;

But I am getting Warning: Cannot modify header information - headers already sent by error.

I am learning WordPress plugin development. I am trying to redirect user to plugins home page after submitting a Form. My code is like below

wp_redirect(plugin_dir_url(__FILE__)); 
exit;

But I am getting Warning: Cannot modify header information - headers already sent by error.

Share Improve this question edited Feb 10, 2020 at 16:21 Foysal asked Feb 10, 2020 at 13:47 FoysalFoysal 4451 gold badge5 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

As in the documentation:

wp_redirect() does not exit automatically, and should almost always be followed by a call to exit;:

wp_redirect( plugin_dir_url(__FILE__) );
exit;
发布评论

评论列表(0)

  1. 暂无评论