0
X
Add Snippet To Project
New Project
Add To Existing Project
<?php
// Plugin Name: WP Plugin
// Function to display registered users in a table
function wpturbo_display_registered_users() {
global $wpdb;
// Get all non-admin users
$users = get_users(array(
'role__not_in' => array('administrator')
));
// Check if any users found
if (empty($users)) {
echo 'No registered users found.';
return;
}
// Table header
echo '<table>';
echo '<thead>';
echo '<tr>';
echo '<th>User ID</th>';
echo '<th>Display Name</th>';
echo '<th>Username</th>';
echo '<th>User Role</th>';
echo '<th>Website</th>';
echo '<th>Biographical Info</th>';
echo '<th>Email</th>';
echo '</tr>';
echo '</thead>';
// Table body
echo '<tbody>';
foreach ($users as $user) {
echo '<tr>';
echo '<td>' . $user->ID . '</td>';
echo '<td>' . $user->display_name . '</td>';
echo '<td>' . $user->user_login . '</td>';
echo '<td>' . implode(', ', $user->roles) . '</td>';
echo '<td>' . $user->user_url . '</td>';
echo '<td>' . $user->description . '</td>';
echo '<td>' . $user->user_email . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
// Display the registered users table
wpturbo_display_registered_users();
Explanation:
