Skip to content

Instantly share code, notes, and snippets.

@adczk
Created April 18, 2024 14:01
Show Gist options
  • Save adczk/aed0cf18477133edf97a863c651c8dc7 to your computer and use it in GitHub Desktop.
Save adczk/aed0cf18477133edf97a863c651c8dc7 to your computer and use it in GitHub Desktop.
Hustle - geolocation integration with Geo Controller plugin
<?php
/**
* Plugin Name: Hustle - geolocation integration with Geo Controller plugin
* Plugin URI: https://gist.github.com/adczk
* Description: Makes Hustle use Geo Controller plugin country detection for country-based visibility rules
* Author: adczk
*
* Author URI: https://gist.github.com/adczk
* License: GPLv2 or later
*
* Use as MU plugin;
*
* Tested with Hustle 7.8.4 and Geo Controller 8.6.5 (https://wordpress.org/plugins/cf-geoplugin/)
*
*/
add_filter( 'hustle_get_user_country', 'wpmudev_geocontroller_user_country', 11, 1);
function wpmudev_geocontroller_user_country( $country ) {
if(class_exists("CF_Geoplugin")){
$cfgeo = new CF_Geoplugin;
$geo = $cfgeo->get();
if ( !empty( $geo->country_code ) ) {
return $geo->country_code;
}
}
return $country;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment