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

Function Reference/wp validate redirect


Validates a URL for use in a redirect.

Checks whether the $location is using an allowed host, if it has an absolute path. Therefore, a plugin can set or remove allowed host(s) to or from the list. If the host is not allowed, then the redirect is to $default supplied @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing WordPress host string and $location host string.


(string) (required) The redirect to validate
Default: None
(string) (optional) The value to return is $location is not allowed

Return Values

redirect-sanitized URL

Change Log

Since: 2.8.1

Source File

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