=== Frontend User Switcher ===
Contributors:      macanderson
Tags:              frontend, user-switching, switch-user, floating-widget, admin
Requires at least: 5.8
Tested up to:      6.9
Requires PHP:      7.4
Stable tag:        1.0.0
License:           GPL-2.0+
License URI:       http://www.gnu.org/licenses/gpl-2.0.txt

Switch WordPress users instantly without leaving the frontend. A beautiful floating widget for developers, support, and testing.

== Description ==

Stop jumping back and forth to the Users dashboard. **Frontend User Switcher** is a "frontend-first" emulation tool that adds a sleek, glassmorphism-styled floating widget to your site's frontend. 

It allows administrators to emulate any user session with one click, directly from the page they are viewing. This is the perfect tool for developers testing membership sites, WooCommerce checkout flows, or restricted content without losing their place on the site.

**Features**

* 🔐 Visible only to administrators — completely invisible to regular users
* 👤 One-click user switching without knowing passwords
* 🔍 Live search / filter across all users
* 🏷️ Role badges (Administrator, Editor, Author, Subscriber, etc.)
* ↩️ "Restore Admin" button appears whenever you are viewing as another user
* 🖥️ Works on the **frontend and backend** (Phase 2) — browse WP Admin as any user
* 🍞 Toast notifications confirm every action before the page reloads
* 🛡️ Secured with WP nonces, capability checks, and session-based origin tracking

== Installation ==

1. Upload the `frontend-user-switcher` folder to `/wp-content/plugins/`.
2. Activate **Frontend User Switcher** in *Plugins → Installed Plugins*.
3. Log in as an administrator and visit any frontend page — the floating button appears at the bottom-left.

== Usage ==

1. Click the floating **avatar button** in the bottom-left corner.
2. Browse or search for a user in the panel.
3. **Click anywhere on a user row** to instantly switch to that user.
4. The page reloads and you are now browsing as that user.
5. A green **Restore** banner shows at the top of the panel — click it to return to your admin account.

== Frequently Asked Questions ==

= Is this safe for production? =
Yes — all AJAX endpoints are protected with a WP nonce and `administrator` capability check. Only logged-in administrators (or sessions originating from one) can trigger a switch. However, treat it like any powerful admin tool and keep your site secure.

= Can I switch back at any time? =
Yes. As long as the PHP session is alive the plugin stores your original admin ID. Click **Restore** in the panel to return.

= What happens if I close the browser while switched? =
The PHP session and auth cookie belong to the switched user. Re-opening the browser will log you in as that user. Log out and log back in as your admin account.

= How many users will the widget list? =
Up to 200 users are loaded on widget render. The live search box searches all users dynamically.

== Screenshots ==

1. The floating widget trigger button (collapsed).
2. The expanded user-switcher panel with search and role badges.
3. The "Restore Admin" banner shown while browsing as another user.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
