DEAL ENDS IN:

SUMMER SALE!

UP TO 35% OFF!

GET IT NOW

Blocking specific users from the geolocation service

You can block certain users from the geolocation service using one of the following functions (or by creating a custom function of your choice):

Block by the user’s IP (or server IP if it’s a bot)

Add the following code to your function.php file, and replace the XX.XX… and YY.YYY… placeholders with the IPs you want to block.

  • The code only blocks the IPs from the geolocation functionality, and not from accessing your website.
  • Blocked IPs will see the default content version.
add_filter('ifso_exclude_from_geo',function($exclude){ $exclude['ip'] = ['XX.XX.XXX.XXX','YY.YYY.YYY.YYY']; return $exclude; });

Block logged-in users

add_filter('ifso_exclude_from_geo',function($exclude){
	if(!is_user_logged_in()){
		$exclude['blockme'] = true;
		return $exclude;
	}
});

Block Administrators

add_filter('ifso_exclude_from_geo',function($exclude){
	if(is_user_logged_in()){
		$user = wp_get_current_user();
		if ( in_array( 'administrator', (array) $user->roles ) ) {
			$exclude['blockme'] = true;
			return $exclude;
		}
	}
});