admin管理员组

文章数量:1394188

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;

本文标签: wp adminRedirect in WordPress plugin