It can be easily done by having the jetFlow.io plugin installed and using the workflow attached to this post.
The workflow tracks user logins in the storage and sends an email notification letter to the admin email with every successful user login. Use download link below to load workflow on the Tools page. Here is description of the workflow.
- We use Hook up trigger to start еру workflow when WordPress
wp_loginaction occurs. Without any conditions.
- To send notification email we use ordinary Send email action. Alternatively we can send push notification to a mobile device or desktop browser with action Send notification via Pushbullet or as a text message by using any of the SMS actions.
- Additionally we track all logins in a default workflow storage with action Save record. The default workflow storage will be created automatically with the first login event. The first column is a user login, second is a display name, third is a user ID, fourth is user’s browser. You can setup column names on your own on the storage settings page.
Track specific user role
If we need to track only specific user role or several roles we need to set the Restrictions for the workflow. Restrictions can be set in the workflow editor. Just select necessary roles from the list in the Restrictions on execution property box on the right side of the editor window and save the workflow. Done!
Track login from specific countries
If you need to track only specific user country or just log countries from what your users are logged in on the website you need to install free WP Cerber security & limit login attempts plugin. It adds a Get WHOIS info action that can be used to obtain detailed WHOIS information about given IP address including country, abuse email, network owner, IP range for a network and other details about IP address.