May 11, 2021
Darko G.

Filters the whitelist of hosts to redirect to.


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.


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

Use case

function my_allowed_redirect_hosts( $hosts ){
    // wrong: $hosts[] = '';
    $hosts[] = '';
    $hosts[] = '';

    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.



Leave a Reply

Your email address will not be published. Required fields are marked *

© 2023 - IP Location Block by IDEOLOGIX Media