Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp safe redirect


Performs a safe (local) redirect, using wp_redirect().

Checks whether the $location is using an allowed host, if it has an absolute path. A plugin can therefore set or remove allowed host(s) to or from the list.

If the host is not allowed, then the redirect is to wp-admin on the siteurl instead. This prevents malicious redirects which redirect to another host, but only used in a few places.


<?php wp_safe_redirect$location$status ); ?>


(string) (required)
Default: None
(integer) (optional)
Default: 302

Return Values

Does not return anything

Change Log

Since: 2.3

Source File

wp_safe_redirect() is located in wp-includes/pluggable.php


See also index of Function Reference and index of Template Tags.