I wrote some code, that helps secure my clients files, and added it to wordpresses function file. however, whenever updates come in, it obviously overwrites my function.
So I wanted to create it as a plugin.
However, I keep getting this error:
PHP Warning: Cannot modify header information - headers already sent by...
So I need to execute my code, BEFORE wordpress sends the headers.
How do I do that?
Thanks, Richard
Update. Okay, here is the code, I changed the tags though, but same premise...
<?php
/*
* Plugin Name: My WP Plugin
* Plugin URI: http://www.example.com/plugins
* Description: My Plugin
* Version: 1.0
* Author: My Name
* Author URI: http://www.example.com/
*/
function somebit_init() {
$_permaStruc = get_option('permalink_structure');
if($_permaStruc != "") {
if($_GET['dl']) {
header("Location: http://google.com");
exit;
} else if($_GET['download']) {
header("Location: http://google.com");
exit;
}
}
}
add_action('init', 'somebit_init');
?>
I'm still getting the "PHP Warning: Cannot modify header information - headers already sent by..." error.
Do you see why? I cannot find it. maybe I did something wrong that I cannot see.
Richard
code
function somebit_init() {/* Do Nothing */ } add_action('template_redirect', 'somebit_init');code
and I still get the error.?>
that is after theadd_action