allowed_redirect_hosts

May 11, 2021
Darko G.

Filters the whitelist of hosts to redirect to.

Description

The filter hook “allowed_redirect_hosts” is to prevent redirection to external sites. It’s a countermeasure especially against the infection of option tables in MySQL database by SQL injection.

Parameters

  • $hosts
    (array) An array of allowed hosts.

Use case

function my_allowed_redirect_hosts( $hosts ){
    // wrong: $hosts[] = 'http://codex.example.com';
    $hosts[] = 'blog.example.com';
    $hosts[] = 'codex.example.com';

    return $hosts;
}
add_filter( 'allowed_redirect_hosts', 'my_allowed_redirect_hosts', 10 );
NOTE: When you select "mu-plugins" (ip-location-block-mu.php) as Validation timing , you should put your code snippet into drop-in.php in Geolocation API folder instead of functions.php. See My custom functions in “functions.php” doesn’t work. in FAQ for detail.

Since

3.0.0

Leave a Reply

Your email address will not be published.

© 2022 - IP Location Block by IDEOLOGIX Media