How to Get the Usernames of Visitors to a Specific Page
Applies to SlimStat 6.0.0 and SlimStat Pro 3.0.0 · checked
You can query recorded usernames for a page with the SlimStat database API. Keep this report private: usernames and browsing histories can identify people. A public shortcode is usually the wrong place for this information.
Administrator-only example
Run this inside WordPress after plugins load, for a known post ID:
if ( current_user_can( 'manage_options' ) && class_exists( 'wp_slimstat' ) ) {
require_once WP_PLUGIN_DIR . '/wp-slimstat/admin/view/wp-slimstat-db.php';
$post_id = absint( get_the_ID() );
wp_slimstat_db::init( 'content_id equals ' . $post_id . '&&&username is_not_empty', false );
$rows = wp_slimstat_db::get_recent( 'username' );
foreach ( $rows as $row ) {
echo '<p>' . esc_html( $row['username'] ?? '' ) . '</p>';
}
}
The default date window is the current month and results are limited by report filters. This is recent recorded activity, not a complete attendance register. Consent, user exclusions and retention determine which records exist.
Pro’s User Overview is useful when you need a ready-made private report for registered-user activity. Compare Pro features or see the database API for custom reporting.