admin管理员组文章数量:1130349
I am getting this error
PHP Warning: Cannot modify header information - headers already sent by (output started at /home/zk2ba8xn663w/public_html/wp-includes/formatting.php:5100) in /home/zk2ba8xn663w/public_html/wp-includes/pluggable.php on line 1219
The error message only shows up if i am activating from TGM plugin actiavtion page, ... if i first install through tgm and then go to actual plugin activation page redirect works with out any problem.
this is the redirect i am using
function activation_redirect( $plugin ) {
if( $plugin == plugin_basename( FILE ) ) {
exit( wp_redirect( admin_url( 'admin.php?page=general-settings' ) ) );
}
}
add_action( 'activated_plugin', 'activation_redirect' );
I am getting this error
PHP Warning: Cannot modify header information - headers already sent by (output started at /home/zk2ba8xn663w/public_html/wp-includes/formatting.php:5100) in /home/zk2ba8xn663w/public_html/wp-includes/pluggable.php on line 1219
The error message only shows up if i am activating from TGM plugin actiavtion page, ... if i first install through tgm and then go to actual plugin activation page redirect works with out any problem.
this is the redirect i am using
function activation_redirect( $plugin ) {
if( $plugin == plugin_basename( FILE ) ) {
exit( wp_redirect( admin_url( 'admin.php?page=general-settings' ) ) );
}
}
add_action( 'activated_plugin', 'activation_redirect' );
Share
Improve this question
asked Nov 18, 2018 at 12:00
user145078user145078
10
|
Show 5 more comments
1 Answer
Reset to default 0Since the standard redirection works, I figured the conflict must be with TGM plugin activation already hooking to activated_plugin and producing output and thus preventing the redirect...
Therefore the solution was to ensure that the plugin activation function hook was added to an earlier priority than the (silent) default of 10 most probably used by TGM:
add_action( 'activated_plugin', 'activation_redirect', 9 );
I am getting this error
PHP Warning: Cannot modify header information - headers already sent by (output started at /home/zk2ba8xn663w/public_html/wp-includes/formatting.php:5100) in /home/zk2ba8xn663w/public_html/wp-includes/pluggable.php on line 1219
The error message only shows up if i am activating from TGM plugin actiavtion page, ... if i first install through tgm and then go to actual plugin activation page redirect works with out any problem.
this is the redirect i am using
function activation_redirect( $plugin ) {
if( $plugin == plugin_basename( FILE ) ) {
exit( wp_redirect( admin_url( 'admin.php?page=general-settings' ) ) );
}
}
add_action( 'activated_plugin', 'activation_redirect' );
I am getting this error
PHP Warning: Cannot modify header information - headers already sent by (output started at /home/zk2ba8xn663w/public_html/wp-includes/formatting.php:5100) in /home/zk2ba8xn663w/public_html/wp-includes/pluggable.php on line 1219
The error message only shows up if i am activating from TGM plugin actiavtion page, ... if i first install through tgm and then go to actual plugin activation page redirect works with out any problem.
this is the redirect i am using
function activation_redirect( $plugin ) {
if( $plugin == plugin_basename( FILE ) ) {
exit( wp_redirect( admin_url( 'admin.php?page=general-settings' ) ) );
}
}
add_action( 'activated_plugin', 'activation_redirect' );
Share
Improve this question
asked Nov 18, 2018 at 12:00
user145078user145078
10
- That would indicate you have something that is throwing an error during the activation processing. It's difficult to track down without additional tools to gain more info on the actual error (which you'll need to know how to fix it). Consider using the "Debug Bar" and "Debug Bar Plugin Activation" plugins to get the actual PHP errors generated during plugin activation. Both are on wp – butlerblog Commented Nov 18, 2018 at 12:58
- @butlerblog can the code i posted be the cause? if i remove that error goes but that does not make sense as there is no redirect there is no error :/. Let me test with plugin you have mentioned – user145078 Commented Nov 18, 2018 at 13:01
- 1 It probably is - although you wouldn't know for certain if you don't use something to get the actual PHP error (which is why I recommended the two tools mentioned - they are extremely helpful in plugin development). I would say that your exit() needs to be separate and after the wp_redirect() call. That's your likely problem. – butlerblog Commented Nov 18, 2018 at 13:04
- And... I'd have to look for sure, but activated_plugin may be too late to actually run a wp_redirect() without a header error. – butlerblog Commented Nov 18, 2018 at 13:05
-
1
if the problem is onlt with TGM you should be looking at that, perhaps it also hooks
activated_plugin? if so you could try adding a priority of 9 so as to run earlier... ie.add_action( 'activated_plugin', 'activation_redirect', 9 );– majick Commented Nov 19, 2018 at 10:53
1 Answer
Reset to default 0Since the standard redirection works, I figured the conflict must be with TGM plugin activation already hooking to activated_plugin and producing output and thus preventing the redirect...
Therefore the solution was to ensure that the plugin activation function hook was added to an earlier priority than the (silent) default of 10 most probably used by TGM:
add_action( 'activated_plugin', 'activation_redirect', 9 );
本文标签: errorsCannot modify header informationheaders already sent during plugin activation
版权声明:本文标题:errors - Cannot modify header information - headers already sent during plugin activation 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749170173a2326866.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


activated_plugin? if so you could try adding a priority of 9 so as to run earlier... ie.add_action( 'activated_plugin', 'activation_redirect', 9 );– majick Commented Nov 19, 2018 at 10:53