Trying to pull users IP and add it to text field

Hi Im working on a user input field for an account creation page associated with an MMO RPG.

In order to make accounts for new players I need the players IP address stored in our database.

Can anyone suggest a way to get the IP Address of a user and add it to our database?

Hey
I think the only way using WIX Code would be setting up a router first where the IP is available. Read more here WixRouterRequest - Velo API Reference - Wix.com.

Or if not tied to just using built in methods why not use this resource https://ipinfo.io/json and when you hit that address using your code you will get back a json object like below and can use that data in your code. Just use fetch to call the api and I hope it does work for client request and not your servers ip.

{
“ip”: “77.91.220.221”,
“city”: “Nyköping”,
“region”: “Södermanland”,
“country”: “SE”,
“loc”: “58.7500,17.0000”,
“org”: “AS43012 Gastabudstaden AB”,
“postal”: “611 63”
}

Dear Andreas,

Would you kindly elaborate a bit more on how one could use the JSON method?

Tony

Hi ML,

Keep in mind that many (most?) users don’t have static IPs. That means that their IP could change each time they visit the site. Not sure how this will impact your site, but you should at be aware of this.

Yisrael