serbon91 on "How to display users location in a page?"

ساخت وبلاگ

serbon91
Member
Posted 16 hours ago #

Hey guys,i was wondering is there a plugin i can use to display a user location within a page, somewhere in the text.
I tried using some of the popular ones,but i dont want to display users location on a map or anything like that,i just want to display a users location in a text within a page. Like in a sentence "Location" Residents can save up to 50% on bla bla bla.
Does any know?

Hi,

If it's only a text sentence, why can't you type it into the content?

Thank you.

Hi serbon91,
Use following line of code where you what to display the users location

if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else { $ip = $_SERVER['REMOTE_ADDR'];
}
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$ip"));
echo $country = $geo["geoplugin_countryName"];

This code show the country of visited user.
Thanks

serbon91
Member
Posted 13 minutes ago #

Because i want to display users location within a sentence,so when a user visits the site it displays his US State it is, primarily for US users so is it possible to displaz just the US State, like Florida,Texas etc...

serbon91
Member
Posted 7 minutes ago #

Btw I am using Divi theme from Elegant themes if that helps anyway.

- - , .
.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 243 تاريخ : يکشنبه 27 تير 1395 ساعت: 2:11