function wp_safe_redirect($location, $status = 302) {}

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.


  • $location
  • $status

Return values

returns:Does not return anything

Source code

function wp_safe_redirect($location, $status = 302) {

	// Need to look at the URL the way it will end up in wp_redirect()

	$location = wp_sanitize_redirect($location);

	$location = wp_validate_redirect($location, admin_url());

	wp_redirect($location, $status);



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: