plugins - location lock wordpress website

Hi I am setting up a WordPress website for a venue. I need to lock the latitude and longitude of the venue so that the w

Hi I am setting up a WordPress website for a venue. I need to lock the latitude and longitude of the venue so that the website only open inside the venue, i tried setting it up on local host to only open with the Wifi but most of the customers use their 4G. any help would be appriciated! Thanks

Hi I am setting up a WordPress website for a venue. I need to lock the latitude and longitude of the venue so that the website only open inside the venue, i tried setting it up on local host to only open with the Wifi but most of the customers use their 4G. any help would be appriciated! Thanks

Share Improve this question asked Jun 27, 2020 at 7:53 Aetzad AsgharAetzad Asghar 155 bronze badges 2
  • I don't think you can. You can write script that asks the client for permission to use their location and submit that back to the website for validation for users that aren't on your wifi, and then set a short-lived cookie (a few hours?) to remember that, but you're relying on the location they send back so you can't guarantee someone isn't trying to trick you. – Rup Commented Jun 27, 2020 at 9:27
  • The only way you could get a trustworthy GPS location for 4G devices is if there was a way to query that from the mobile networks. But there almost certainly isn't. You could ask everyone to connect to wifi briefly, and use that to set a cookie that your site can check once they switch back to 4G, but that's making your wifi a single point of failure and in my experience venue wifi isn't reliable. – Rup Commented Jun 27, 2020 at 9:29
Add a comment  | 

1 Answer 1

Reset to default 0

There are open/free APIs that allow geolocation based on the IP address. IP address of a mobile should be geo-correct.

I use this site, with a CURL function to return the Geo information. Go to the URL in the code to get details on the return values.

function grabIpInfo($ip) {
    //$ip = '185.164.57.189'; // france
    //$ip = '110.33.122.75'; // australia
    $curl = curl_init();

    curl_setopt($curl, CURLOPT_URL, "https://api.ipgeolocationapi/geolocate/" . $ip);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

    $returnData = curl_exec($curl);

    curl_close($curl);

    return $returnData;
}

You'll need to pass the IP address, which is available with

$_SERVER["REMOTE_ADDR"]

That might get you started on the code you need. And testing (I hard coded some other-country IP addresses for my testing, as shown in the code).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742297140a4417353.html

相关推荐

  • plugins - location lock wordpress website

    Hi I am setting up a WordPress website for a venue. I need to lock the latitude and longitude of the venue so that the w

    17小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信