=== AddonLogic Login Redirect By Role ===
Contributors: snehalpancholi
Tags: login redirect, role redirect, user role, after login, logout redirect
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.1
Stable tag: 1.0.0
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Redirect users to role-specific URLs after login. Supports per-role redirect rules, a default fallback URL, and optional logout redirect.

== Description ==

**AddonLogic Login Redirect By Role** gives site administrators full control over where each user role lands after logging in. Instead of every user going to the WordPress dashboard, you can send:

* Administrators to the dashboard (or leave them on the default)
* Editors to the Posts list
* Authors to their own profile or a custom editorial dashboard
* Contributors to a welcome page
* Subscribers to their account page or any front-end URL
* Any custom role to its own destination

**Features:**

* Per-role redirect URL configuration via a clean admin table
* Role priority system — if a user has multiple roles, the highest-priority role wins
* Default fallback URL for roles without a specific rule
* Optional logout redirect (using `wp_safe_redirect` for security)
* Live preview table showing exactly what each role will experience
* Zero bloat — no custom database tables, no JavaScript dependencies on the front end
* Automatic updates from the AddonLogic update server

== Installation ==

1. Upload the `login-redirect-by-role` folder to `/wp-content/plugins/`.
2. Activate the plugin from **Plugins > Installed Plugins**.
3. Navigate to **Settings > Login Redirect**.
4. Enter redirect URLs for the roles you want to control.
5. Optionally enable the logout redirect and enter a destination URL.
6. Click **Save Redirect Rules**.

== Frequently Asked Questions ==

= What happens if I leave a role's URL blank? =

The plugin falls through to the next rule. If the Default Fallback URL is set, that is used. If neither is set, WordPress uses its built-in logic (usually the admin dashboard or the URL the user was trying to reach).

= What if a user has multiple roles? =

The plugin resolves by role priority. Standard WordPress roles are checked in this order: Administrator, Editor, Author, Contributor, Subscriber. The first role in that list that has a URL configured wins.

= Is the logout redirect safe? =

Yes. The plugin uses `wp_safe_redirect()`, which only allows redirects to the same domain or URLs explicitly allowlisted via the `allowed_redirect_hosts` filter.

= Does this affect the WordPress admin "Send Reset Link" emails? =

No. The plugin only hooks into `login_redirect` (post-login) and `wp_logout` (post-logout). Password reset flows are not affected.

= Will this work with custom roles added by other plugins? =

Yes. The plugin dynamically reads all roles registered in WordPress. Custom roles appear in the settings table below the standard roles, ordered alphabetically.

== Screenshots ==

1. Settings page — per-role URL table with priority badges
2. Default fallback and logout redirect configuration
3. Live preview panel showing current redirect destinations

== Changelog ==

= 1.0.0 =
* Initial release.
* Per-role login redirect URLs.
* Default fallback URL.
* Logout redirect with wp_safe_redirect.
* Live preview panel in admin.
* Auto-update via AddonLogic update server.
