How to receive notifications with location info whenever anyone logs in

I wanted to know whenever anyone logs into a site I’ve built as a security feature (much like Wordfence does for Wordpress sites) and it’s incredibly easy with Wappler so I thought I’d give a bit back to this great community and show how I did it.

In my login Server Action I have one Global which is in $_SERVER and is called REMOTE_ADDR. This will store the user’s IP address.

I signed up to the free service at which is an API for resolving IP addresses and giving location information. It’s very easy to use with the API Server Action in Wappler. You need to register for the free account to get your access_key.

The API Server Action should be set up like this:

ID: apiResolveIP
Output: ticked
Pass Errors: ticked
Method: GET
Data Type: Auto
Authorization: None

Then add one entry to the Query list.
Name: access_key

After entering all those details, click on the ‘Define API Schema’ button and then ‘Fetch Schema’ to get all the variables so it’s easy to use them in your email template.

Finally, set up your email settings using all the variables now at your disposal. My email template looks like this:

Someone has just logged into your website.
ID: {{security1.identity}}
Name: {{queryLoggedInUser.uFirstName}} {{queryLoggedInUser.uLastName}}
Email: {{queryLoggedInUser.uEmail}}
Location: {{}}, {{}}
Country: {{}} ({{}})

You’ll notice I added a condition so that I don’t receive lots of emails for any attempted logins. It’s only the successful ones which trigger the email.


Hi @sitestreet
Thanks for sharing this :slight_smile:

Just a comment - you can use just {{security1.identity}} as an expression for the condition.


Aah, yes, of course. Forgot about that. I’ve now streamlined my server action :slight_smile:


Nice idea, thank you @sitestreet, I will probably implement something similar on one of my projects.

1 Like

Hi Sitestreet,
Do I understand that we don’t need to use API Access Key in the API Server Action?

Hi @Djibril. Do you mean for IPStack? You do need to use an API key but they are free.

1 Like

Thnks for share, good idea!

1 Like

Hi, very nice to share!

About the Remote Address when you set under $_SERVER the variable REMOTE_ADDR, does it take automatically the remote IP or do you need to set some operations?

Thank you


1 Like

@updates, that variable automatically returns the IP address of the visitor, yes. You don’t need to do anything else.