Created
April 18, 2024 14:01
-
-
Save adczk/aed0cf18477133edf97a863c651c8dc7 to your computer and use it in GitHub Desktop.
Hustle - geolocation integration with Geo Controller plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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