=== User Registration Stats ===
Contributors: AlixZarei
Donate link: https://alixzarei.ir/
Tags: users, statistics, analytics, registration, utm tracking
Requires at least: 5.0
Tested up to: 7.1
Requires PHP: 7.2
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Track and visualize your WordPress user registration statistics with daily, monthly, and yearly insights, advanced UTM tracking, and CSV export.

== Description ==

User Registration Stats is a comprehensive, performance-optimized plugin designed to provide WordPress site administrators with clear and actionable insights into their user acquisition trends. It automatically tracks new user sign-ups and presents this data in a beautifully designed, modern dashboard within the WordPress admin area. 

Built with scalability in mind, this plugin handles high-traffic sites effortlessly by utilizing advanced database optimization (SQL JOINs, custom indexes) and intelligent caching mechanisms (Transients API).

**Key Features:**

* **Advanced Source Tracking:** Uses a smart 30-day cookie-based system to accurately track UTM parameters (`utm_source`, `utm_medium`, `utm_campaign`) and Referral links, ensuring no data is lost if a user browses before registering.
* **Modern Dashboard UI:** A completely redesigned, responsive interface using lightweight SVG icons and Chart.js for beautiful 30-day trend visualizations. Fully RTL compatible.
* **Frontend Shortcode:** Display key registration metrics on the frontend (client portals or public pages) using the `[user_reg_stats]` shortcode.
* **User Role Tracking:** Automatically captures and displays the assigned user role upon registration.
* **Timeframe Aggregation:** Quickly view stats for Today, Last 7 Days, This Month, and This Year.
* **WordPress Dashboard Widget:** Get a quick glance at your daily and total registrations right from the main WordPress dashboard.
* **Robust CSV Export:** Export filtered data including User Roles and UTM tags. The export engine is optimized to process thousands of rows without timing out.
* **Silent Updater:** Seamlessly upgrades database schemas in the background without any data loss.
* **Complete Cleanup:** Secure data clearing options and a full uninstallation routine for complete data removal.

== Installation ==

1.  **Automatic Installation (Recommended):**
    * In your WordPress dashboard, navigate to `Plugins` > `Add New`.
    * Search for "User Registration Stats".
    * Click `Install Now` and then `Activate`.

2.  **Manual Installation:**
    * Download the plugin's ZIP file from its WordPress.org page.
    * In your WordPress dashboard, navigate to `Plugins` > `Add New`.
    * Click `Upload Plugin`.
    * Choose the downloaded ZIP file and click `Install Now`.
    * Activate the plugin.

3.  Once activated, a "User Stats" menu item will appear in your WordPress admin sidebar.

== Frequently Asked Questions ==

= Does this plugin track users added manually by an admin? =
Yes, it tracks all new user registrations, including those added manually, by hooking into the standard `user_register` action.

= How are registration sources tracked? =
The plugin uses an advanced 30-day cookie tracking system. If a user visits your site via a referral link or a campaign URL with UTM parameters, the data is saved in their browser and recorded when they successfully register.

= Will this plugin slow down my high-traffic site? =
No. The plugin is strictly optimized for performance. It uses the WordPress Transients API to cache heavy statistical queries and employs optimized SQL indexing to ensure zero impact on your site's load speed.

= How can I display the stats on the frontend? =
You can use the `[user_reg_stats]` shortcode on any post, page, or widget to display a modern stats box.

= Can I clear the statistics collected by this plugin? =
Yes, the "Clear All Statistics" button in the "Data Management" section will safely truncate the logs while keeping the plugin functional.

= What happens when I uninstall (delete) the plugin? =
The `uninstall.php` script will run, permanently removing the plugin's custom database table and all its options.

== Screenshots ==

1. The modern and responsive statistics dashboard.
2. Registration Log with User Role and UTM tracking.
3. Convenient WordPress Dashboard widget.

== Changelog ==

= 1.1.0 =
* [NEW] Advanced 30-day cookie-based UTM and Referral tracking system for highest accuracy.
* [NEW] Frontend shortcode `[user_reg_stats]` for public or client-facing stats display.
* [NEW] User Role tracking added to the dashboard logs and CSV exports.
* [NEW] WordPress Dashboard Widget for a quick overview of daily and total stats.
* [NEW] Weekly, Monthly, and Yearly aggregated metrics on the main overview card.
* [IMPROVED] Fully redesigned Admin UI using modern SVG icons, a clean color palette, and full RTL support.
* [IMPROVED] Massive performance optimizations for large-scale sites (Transients API caching, optimized SQL JOINs, and DB indexes).
* [IMPROVED] Enhanced and bulletproof CSV export system for handling high-volume user data safely.
* [IMPROVED] Silent database updater mechanism for seamless schema upgrades.

= 1.0.4 =
* [FIXED] Retrieves data formatted for the 30-day registration trend chart.

= 1.0.3 =
* Initial public release.