Introducing the User Signup Stats Script for WordPress
Managing user engagement is key to understanding the growth of your WordPress site. The User Signup Stats Script is designed to simplify this process by providing insightful data about your user registrations directly in your WordPress dashboard.
This Script offers an intuitive interface that displays three core statistics:
- Total Users – The total number of registered users on your site.
- Most Signups in a Day – The highest number of users who signed up in a single day, along with the specific date.
- Signups Chart – A visually appealing chart that shows daily signup trends, giving you a clear picture of your site’s growth over time.
One standout feature of the chart is its interactivity. When you hover over any data point, it displays detailed information about that specific day, including the date and the exact number of user signups. This makes it incredibly easy to analyze trends and identify days of peak activity at a glance.
The data is presented in an easy-to-read format with styled boxes and a responsive chart powered by Chart.js. With its clean design and useful insights, the plugin helps site administrators monitor trends and track user engagement without needing complex tools or external reports.
Whether you’re running a membership site, an online course platform, or a community blog, the User Signup Stats Script is a must-have tool to track your user growth and identify peak registration days. This valuable data can help you plan campaigns, optimize your content strategy, or simply celebrate your site’s progress.
Get started today and take control of your user signup insights!
- To convert this into a plugin just simple add <?php to line one, next you will need to zip it and upload it the normal way of adding a plugin.
- To use a code snippet plugin simple create a new functions script copy and paste and it will display in the user dashbaord.
I use fluent snippet plugin for all my functions, js, and CSS:
/*
Plugin Name: User Signup Stats
Description: Displays total users, most user signups in a day, and a chart of user signups over time.
Version: 1.0
Author: Scot Birchfield
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
class UserSignupStats {
public function __construct() {
add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']);
add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
}
// Add dashboard widget
public function add_dashboard_widget() {
wp_add_dashboard_widget(
'user_signup_stats_widget',
'User Signup Stats',
[$this, 'render_dashboard_widget']
);
}
// Enqueue scripts for the chart
public function enqueue_scripts($hook) {
if ($hook === 'index.php') {
wp_enqueue_script('chartjs', 'https://cdn.jsdelivr.net/npm/chart.js', [], '3.7.0', true);
wp_add_inline_script('chartjs', $this->get_chart_script());
}
}
// Get user signup data
private function get_signup_data() {
global $wpdb;
$results = $wpdb->get_results("SELECT DATE(user_registered) as signup_date, COUNT(*) as count FROM {$wpdb->users} GROUP BY signup_date", ARRAY_A);
$data = [
'labels' => [],
'counts' => [],
];
foreach ($results as $result) {
$data['labels'][] = date('m/d/Y', strtotime($result['signup_date']));
$data['counts'][] = (int) $result['count'];
}
return $data;
}
// Generate inline JavaScript for the chart
private function get_chart_script() {
$signup_data = $this->get_signup_data();
$labels = json_encode($signup_data['labels']);
$counts = json_encode($signup_data['counts']);
return "
document.addEventListener('DOMContentLoaded', function() {
const ctx = document.getElementById('signupChart').getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: $labels,
datasets: [{
label: 'User Signups',
data: $counts,
backgroundColor: '#99D1F4', // Solid background color for the chart area
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1,
fill: true
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
});
});
";
}
// Render the dashboard widget
public function render_dashboard_widget() {
$total_users = count_users();
$signup_data = $this->get_signup_data();
$most_signups = max($signup_data['counts']);
$most_signups_day = $signup_data['labels'][array_search($most_signups, $signup_data['counts'])];
?>
<div style="display: flex; gap: 15px;">
<div style="flex: 1;background:#F6F7F7;border:1px solid #DCDCDE;">
<h2 style="text-align:center;">Total Users</h2>
<p style="font-size: 16px;text-align:center;font-weight:bold;"> <?php echo $total_users['total_users']; ?> </p>
</div>
<div style="flex: 1;background:#F6F7F7;border:1px solid #DCDCDE;">
<h2 style="text-align:center;">Most Signups in one day</h2>
<p style="font-size: 16px;text-align:center;font-weight:bold;"> <?php echo $most_signups; ?> on <?php echo $most_signups_day; ?> </p>
</div>
</div>
<div style="margin: 15px 0px 15px 0px;">
<h2 style="text-align:center;">Signups Chart</h2>
<canvas id="signupChart"></canvas>
</div>
<?php
}
}
new UserSignupStats();
?>
Enjoy and if you have any question please post them in the comments below or use my contact form.
Notes:
This basic script, CSS style, and plugin are designed to function optimally assuming minimal interference from your theme or other plugins. If conflicts occur or further customization is needed, additional adjustments may be necessary. Please note that this script, CSS style, or plugin must be used AS IS.
Wp Scriptly
Comments: