=== WpSocialManager ===
Contributors: kc-dev
Tags: community, membership, rbac, custom-tables, family-records
Requires at least: 4.5
Tested up to: 7.0.3
Requires PHP: 8.0
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Social community group memberships with their own login, roles, and family records — entirely independent of WordPress user accounts.

== Description ==

WpSocialManager runs a self-contained community membership system alongside WordPress: registration, email verification, login, roles (admin/moderator/member), and per-member family records, all stored in dedicated tables (`wp_wpsm_members`, `wp_wpsm_family_members`, `wp_wpsm_sessions`, `wp_wpsm_login_attempts`) and authenticated with a standalone session cookie — never `wp_users` or `wp_usermeta`.

A WordPress Administrator (`manage_options`) is automatically linked to a community profile with the `admin` role the first time they open the portal or the admin console, so they can manage the community and their own profile/family without registering separately, and can toggle a "View as Member" switcher to preview the non-privileged experience.

= Shortcodes =

* `[wpsm_portal]` — the full member dashboard: login/register forms for guests, then Profile and Family tabs once logged in, plus a Members tab (admins/moderators) and Reports tab (admins).
* `[wpsm_register]` — a standalone registration form.
* `[wpsm_login]` — a standalone login form.

= Admin console =

Under KC-Dev → WpSocialManager: a searchable/filterable/paginated Members DataGrid with a detail drawer, role/status editing, bulk actions (activate/suspend/delete/change role), CSV export, and a Reports tab with age/gender/role demographics.

= Security =

Passwords are hashed with `wp_hash_password()`; every SQL query is `$wpdb->prepare()`d; state-changing REST requests require a valid `X-WP-Nonce`; failed logins are rate-limited per identifier and per IP (5 attempts / 15 minutes); email/phone verification uses a cryptographically random, time-limited token.

== Installation ==

1. This plugin requires the KC-Dev admin framework mu-plugin present in this environment (`wp-content/mu-plugins/kcdev-framework/`) for its settings menu — on a site without it, `includes/kcdev-compat.php` provides a standalone fallback automatically.
2. Activate the plugin — this creates the four custom database tables.
3. Add `[wpsm_portal]` to a page for the member dashboard.
4. Configure the master enable switch under KC-Dev → WpSocialManager → Settings.

== Changelog ==

= 1.5.0 =
* New page template, "WpSocialManager: Full Width (No Theme)" — selectable per-page under Page Attributes → Template on any page. Renders that page's content with no active theme header/footer/sidebar (`wp_head()`/`wp_footer()` still run, so the portal's own scripts/styles load normally), so the theme's own layout/CSS can't clash with the portal's. Works with any theme, registered by the plugin itself rather than requiring theme changes.

= 1.4.3 =
* Fixed a fatal error ("Class \"KCDev_Admin\" not found") on any WordPress site that doesn't have the KC-Dev framework mu-plugin installed — every `[wpsm_portal]`, `[wpsm_register]`, or `[wpsm_login]` shortcode crashed the page it was on. This plugin is designed to also run standalone (see `includes/kcdev-compat.php`), but one stylesheet enqueue referenced the framework's class directly without the same function_exists()-style guard used everywhere else; it's now skipped gracefully when the framework isn't present.

= 1.4.2 =
* Fixed: wp-admin's Members Console, Reports, and CSV/Excel export could return "Sorry, you are not allowed to do that." for a real admin/moderator if the portal's "View as Member" cookie was still set from an earlier visit (that cookie isn't scoped to the portal page). Those checks now always use the real community role — "View as Member" only ever affects what renders inside the portal itself.

= 1.4.1 =
* Custom Fields and Activity Groups management moved out of the wp-admin console entirely, into new admin-only "Fields" and "Groups" tabs on the `[wpsm_portal]` dashboard — so a standalone community admin (no WordPress account) can manage them too, not just a WordPress Administrator.

= 1.4.0 =
* Activity Groups now have a Type: "regular" or "event". An event group can optionally carry a start date, or a start/end date range, shown next to the group everywhere it's listed (admin console, member/family checkbox lists).

= 1.3.0 =
* Admin-defined Activity Groups (KC-Dev → WpSocialManager → Activity Groups): name, description, and an optional photo (uploaded to the Media Library). Members can put themselves and/or their family members into one or more groups via a checkbox list on the registration, profile, and family forms.

= 1.2.0 =
* Admin-defined custom fields for Member and Family records (KC-Dev → WpSocialManager → Custom Fields): text, textarea, number, date, email, url, select, and checkbox types, each with an optional required flag and helper text. Fields appear automatically — with matching input type, validation, and helper text — on the registration form, profile edit, family add/edit, and the admin console's member detail drawer.

= 1.1.0 =
* Excel (.xlsx) export in normalized (Members + Family sheets) and flattened (joined) forms, alongside the existing Members/Family CSV exports.
* Phone field is now a country-code dropdown (defaults to India +91) plus a local-number input, on both registration and profile edit.
* Client-side email format validation on registration.
* Every WordPress Administrator is imported into the Members Console at plugin activation, not just whoever happened to be logged in at the time.
* Fixed low-contrast family-card edit/delete buttons, and unified the Members Console toolbar's search/filter control heights and widths.

= 1.0.0 =
* Initial release: standalone auth/RBAC engine, member + family CRUD, REST API, frontend portal, admin console with reports and CSV export.
