=== LoginLens – Account Sharing Detector ===
Contributors: eyargilad
Tags: account sharing, password sharing, membership, concurrent logins, login log
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See which members share their login, without locking out honest customers. Logs devices, networks and simultaneous use, and flags suspicious accounts.

== Description ==

Most anti-sharing plugins just cap concurrent logins. That stops sharing, but it also kicks out the member who reads on their phone and their laptop.

LoginLens takes the other approach: it **watches and reports** so you can decide what to do. It never blocks a login.

**What it detects**

* **Simultaneous use:** different devices actively using the same account within the same 15 minutes. This is the strongest sign of sharing.
* **Too many devices:** many different browser, OS and device combinations in a short window.
* **Too many networks:** logins from many different networks, for example several cities in one day.
* **Shared login cookies:** an existing session suddenly appearing from another network.

**What you get**

* Users → Account Sharing: flagged accounts, ranked most suspicious first, with the reason for each flag.
* A page for each account showing open sessions right now (with which ones are live), its devices, and the full event log.
* Country of each login when your site is behind Cloudflare (read from the CF-IPCountry header, so no lookups and no external calls). Tor exit nodes are labelled.
* Clickable IPs: open a lookup page for any IP in one click.
* A one-click "Log out of all devices" button.
* Optional email alerts, sent at most once per account per window.
* Thresholds you can adjust, plus roles to exclude (administrators are excluded by default).

**Works with any login form.** It hooks into WordPress core logins and sessions, so it works with wp-login.php, Elementor login forms, WooCommerce, MemberPress, LearnDash, Paid Memberships Pro and others.

**Lightweight.** Each session's "last seen" time is updated at most once every 5 minutes. Ordinary page loads add no database writes.

**Privacy-friendly.** No external services, no tracking and no fingerprinting. Devices are recorded only at a "Chrome on Windows" level. Logs are deleted automatically after a retention period you choose (90 days by default). The data is included in WordPress's Export and Erase Personal Data tools, and a privacy-policy paragraph is suggested for you under Settings → Privacy.

== Installation ==

1. Install and activate the plugin.
2. Go to **Users → Account Sharing → Settings** and review the thresholds.
3. If your site is behind Cloudflare or a reverse proxy, set **Client IP source**. Otherwise every visitor will appear to share one IP.
4. Check **Users → Account Sharing** after your members have been active for a day or so.

== Frequently Asked Questions ==

= Will it log out or block my members? =

No. It only records and reports. You can end a member's sessions manually from their account page.

= Won't someone with a phone and a laptop be flagged? =

Not with the default settings. An account is flagged at 3 or more devices active at the same time, 4 or more distinct devices, or 5 or more networks within 24 hours. All three thresholds can be changed.

= Every user shows the same IP address. =

Your site is behind a proxy or CDN. Choose the matching header in Settings → Client IP source.

= Why don't I see a Country column? =

Country comes from Cloudflare's CF-IPCountry header, so it only appears when your site is behind Cloudflare, and only for events recorded after that. You can also supply countries from your own GeoIP source with the `loginlens_client_country` filter.

= Does clicking an IP send data anywhere? =

Only if you click it. The link opens ipinfo.io in a new tab, from your own browser. The plugin never contacts it. Use the `loginlens_ip_lookup_url` filter to choose another service, or return an empty string to turn the links off.

= Does it work on multisite? =

Yes. Each site keeps its own log.

= Developers: are there hooks? =

* `loginlens_client_ip` (filter): override the detected IP.
* `loginlens_is_user_excluded` (filter): exclude specific users.
* `loginlens_event_recorded` (action): runs after each event, with the user ID, event type and number of live devices.
* `loginlens_client_country` (filter): set a two-letter country code from your own GeoIP source.
* `loginlens_ip_lookup_url` (filter): the IP lookup URL pattern, where `%s` is the IP. Return an empty string to turn the links off.
* `loginlens_waitlist_url` (filter): the URL of the early-access link (empty hides it).

== Screenshots ==

1. Flagged accounts, most suspicious first, with the reason for each flag.
2. An account's page: why it's flagged, open sessions (live ones in red), and one-click "Log out of all devices".
3. The event log: every login, simultaneous use and network change, with country (via Cloudflare), Tor detection and clickable IPs.
4. Settings: thresholds, email alerts, excluded roles and the proxy/CDN IP source.

== Changelog ==

= 1.0.0 =
* Initial release.
