Thread Starter
goxu
(@goxu)
Ok,
If I embed the following code at the very beggining of the wp-admin/admin-header.php it works.
header( 'Location: ' . get_settings('siteurl') );
exit();
However, if I do this as a plugin,
/*
Plugin Name: Go Home
Plugin URI:
Description: forces anybody to go home
Version: 0.1beta
Author: Goxu
Author URI:
*/
function force_gohome() {
header( ‘Location: ‘ . get_settings(‘siteurl’) );
exit();
}
add_action (‘admin_header’, ‘force_gohome’ ,1);`
The priority is set to 1, so I assume that the funciton will be loaded prior to anyother funciotns. Am I correct?
If so, why doesn’t it work? Any information will be greatly appreciated.
Thread Starter
goxu
(@goxu)
I haven’t been able to figure out yet.
There was a minor mistake in the last line. the ‘admin_header’ had to be ‘admin_head’.
Still, I keep getting the following error in the admin panel after enabling this plugin. Is it only me getting this or do you also get this error too?
Warning: Cannot modify header information – headers already sent by (output started at /home/wordpress/wp-admin/admin-header.php:16) in /home/wordpress/wp-content/plugins/force_gohome.php on line 12
<?
/*
Plugin Name: Go Home
Plugin URI: http://example.com
Description: forces anybody to go home
Version: 0.1beta
Author: Goxu
Author URI: http://example.com
*/
function force_gohome(){
header('Location: ' . get_settings('siteurl'));
exit();
}
add_action('admin_head', 'force_gohome', 1);
?>
Thread Starter
goxu
(@goxu)
The ‘init’ hook did the job.