β²οΈ Estimated reading time: 5 min
Want to keep an eye on your WordPress site’s activities? Learn how to create a custom dashboard panel to Monitor Logs, post edits, and more all from your admin area. Perfect for security, maintenance, and transparency.
How to Create a Custom WordPress Dashboard Panel For Website Monitor Logs
Monitoring your WordPress websiteβs activity is crucial for keeping it secure and well-maintained. Whether you’re managing a single-author blog or a multi-user platform, knowing who logs in, what content changes, and when it happens can make a huge difference in tracking suspicious behavior or simply maintaining accountability.
In this guide, youβll learn how to create a custom dashboard panel in WordPress that logs two key activities:
- User logins (with timestamp and IP address)
- Post edits (with editor name and time)
This custom panel will appear directly on your WordPress Dashboard, making it accessible immediately after logging in. It’s a lightweight, code-only solution that doesnβt rely on third-party plugins.
Why Monitor Website Logs?
WordPress doesnβt show detailed backend activity by default. For example, it doesnβt log:
- When users log in and from where
- Who edited what content and when
- Activity trends over time
By creating your own panel, you can keep your admin area informative and secure, without bloating your site with heavy monitoring plugins.
Step-by-Step Guide to Add Website Logs Panel to WordPress
1. Where to Add the Code
You can either:
- Add this code to your themeβs
functions.php
file (not recommended for production sites unless using a child theme). - Or create a custom plugin for this purpose.
For flexibility and updates, the plugin route is better.

2. The Full PHP Code
Here is the complete code that adds the dashboard panel and logs user login and post update activities:
// Add dashboard widget
add_action('wp_dashboard_setup', 'custom_website_logs_panel');
function custom_website_logs_panel() {
wp_add_dashboard_widget(
'custom_logs_panel',
'Website Logs Monitor',
'display_website_logs_panel'
);
}
function display_website_logs_panel() {
echo '<h4>Recent Logins</h4>';
display_recent_logins();
echo '<hr>';
echo '<h4>Recent Post Updates</h4>';
display_recent_post_updates();
}
// Track user logins
add_action('wp_login', 'track_user_login', 10, 2);
function track_user_login($user_login, $user) {
$logins = get_option('custom_login_logs', []);
array_unshift($logins, [
'time' => current_time('mysql'),
'user' => $user_login,
'ip' => $_SERVER['REMOTE_ADDR']
]);
update_option('custom_login_logs', array_slice($logins, 0, 10));
}
function display_recent_logins() {
$logins = get_option('custom_login_logs', []);
if (empty($logins)) {
echo '<p>No login records found.</p>';
} else {
echo '<ul>';
foreach ($logins as $log) {
echo "<li><strong>{$log['user']}</strong> logged in at {$log['time']} from IP {$log['ip']}</li>";
}
echo '</ul>';
}
}
// Track post edits
add_action('post_updated', 'track_post_updates', 10, 3);
function track_post_updates($post_ID, $post_after, $post_before) {
if ($post_after->post_status !== 'publish') return;
$updates = get_option('custom_post_update_logs', []);
array_unshift($updates, [
'time' => current_time('mysql'),
'post_id' => $post_ID,
'title' => get_the_title($post_ID),
'editor' => wp_get_current_user()->user_login,
]);
update_option('custom_post_update_logs', array_slice($updates, 0, 10));
}
function display_recent_post_updates() {
$updates = get_option('custom_post_update_logs', []);
if (empty($updates)) {
echo '<p>No recent post updates.</p>';
} else {
echo '<ul>';
foreach ($updates as $update) {
$url = get_edit_post_link($update['post_id']);
echo "<li><strong>{$update['title']}</strong> edited by {$update['editor']} at {$update['time']} <a href='{$url}'>Edit</a></li>";
}
echo '</ul>';
}
}
How This Helps You
This panel gives you a clear snapshot of recent activity on your site. You can use it to:
- Catch unauthorized access quickly
- Identify which team member made specific changes
- Keep historical logs for internal review
Itβs also useful when collaborating with content editors, writers, or client websites.
Tips to Extend Functionality
Want to monitor more than just logins and post edits? Consider adding:
- Plugin activation/deactivation logs
- Page edits and media uploads
- Custom post type changes
- WooCommerce order events
- 404 or error logs
With a little expansion, you can turn this into a full-fledged mini-audit system.
Make It a Monitor Logins Plugin (Optional but Recommended)
If you want to turn this code into a standalone plugin:
- Create a folder in
/wp-content/plugins/
calleddashboard-logs-monitor
. - Inside it, create a file
dashboard-logs-monitor.php
and paste the code. - Add the plugin header:
<?php
/*
Plugin Name: Dashboard Logs Monitor
Description: Adds a custom dashboard panel to monitor logins and post edits.
Version: 1.0
Author: Your Name
*/
- Activate the plugin from the admin panel.
Creating a custom dashboard panel to track WordPress activity is an efficient and clean solution to monitor important changes on your website. It offers a real-time glance at whoβs doing what and itβs lightweight, secure, and fully under your control.
You donβt need bulky plugins when you can build powerful tools like this yourself using native WordPress hooks and options.
π© Do you have questions or suggestions? Leave a comment or contact us!
π·οΈ Tags: wordpress dashboard, admin panel, user login logs, post edit logs, wordpress hooks, security monitoring, custom plugin, wp_dashboard_setup, php tutorial, wordpress audit
π’ Hashtags: #WordPress #DashboardPanel #WebsiteLogs #CustomPlugin #WebSecurity #PHP #WPAdmin #PostUpdates #LoginTracker #WPDevelopment
Discover more from HelpZone
Subscribe to get the latest posts sent to your email.