[wp-hackers] internal redirects

Peter Westwood peter.westwood at ftwr.co.uk
Tue Apr 27 18:02:04 UTC 2010

On 27 Apr 2010, at 18:47, Otto wrote:

> If you're going to do redirects, best to do them as early as possible.
> I have plugin code that looks basically like this:
> if (array_key_exists('my_check_thingy', $_GET) &&
> $_GET['my_check_thingy'] == 1) { ?>
> ... logic for redirect ...
> }
> This happens right at plugin load. No waiting about, no loading the
> query, just do it. Works fine, speedy as heck.

Doing things as early as possible is good.

Doing things when your plugin is included is not recommended.

Better to use the earliest available suitable hook - plugins_loaded / init / wp_loaded (3.0 and later only)

That way you can ensure that all the WordPress core functionality you might be relying on will always be available.

Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5

More information about the wp-hackers mailing list