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