PHP Functions

You are here:

If you need you have a set of php functions to interact with the plugin without the need of using shortcodes. Be sure to wrap all your functions in a function_exists() block to avoid fatal errors when plugin is not enabled. Eg:

function_exists

1
2
3
4
5
if( function_exists( 'geot_target' ) ) {
    if( geot_target( 'Argentina' ) ) {
        echo 'Only show to Argentina';
    }
}

Targeting functions

geot_user_country

1
2
3
4
5
// Return object of current user country details
$country = geot_user_country();
 
echo $country->name;
echo $country->isoCode;

geot_country_code

1
2
3
// return current user country code
 
echo 'You country code is : ' . geot_country_code();

geot_country_name

1
2
3
// return current user country name
 
echo 'You country name is : ' . geot_country_name();

geot_country_by_ip

1
2
3
4
5
// Return country by given ip or current user if not ip is given
// $country->name $country->isoCode
$country = geot_country_by_ip("190.188.153.122");
 
echo 'Your country is : '. $country->name;

geot_state_by_ip

1
2
3
4
5
// Return state by given ip or current user if not ip is given
// $state->name $state->isoCode
$state = geot_state_by_ip("190.188.153.122");
 
echo 'Your state is : '. $state->name;

geot_city_name

1
2
3
// Return current user city name
 
echo 'Your city is: '. geot_city_name();

geot_zip

1
2
3
// Return current user zip code
 
echo 'Your zip is: '. geot_zip();

geot_time_zone

1
2
3
// Return current user time zone
 
echo 'Your time zone is: '. geot_time_zone();

geot_radius

1
2
3
// Return current user radius
 
echo 'The accuracy radius is: '. geot_accuracy_radius();

geot_lat

1
2
3
// Return current user lat
 
echo 'Your latitude is: '. geot_lat();

geot_lng

1
2
3
// Return current user lng
 
echo 'Your longitude is: '. geot_lng();