X

Add Total Members to “Right Now” Dashboard Widget

Snippets by IsItWP

Do you want to display total number of users in the “Right Now” dashboard widget? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add total members to “Right Now” dashboard widget in WordPress.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function dashboard_wps_user_count() {
    global $wpdb;
    $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
?>
<table>
    <tbody>
       <tr class="first">
          <td class="first b b_pages"><a href="users.php"><? echo $users; ?></a></td>
          <td class="t pages"><a href="users.php">Members</a></td>
       </tr>
     </tbody>
</table>
<?}
add_action( 'right_now_content_table_end', 'dashboard_wps_user_count');

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 28 best WordPress resume themes and how to create a WordPress donation form.

Comments   Leave a Reply

  1. Hi Kein, Happy to land here!! 🙂
    Thanks for this great snipp!
    Is it possible to add custom post type count also? 🙂

  2. This seems to have a number of issues Kevin. For those that may not know the <?} will throw an error. Also, "Members" on the dashboard doesn't show a count.

    1. What issues are you having with the snippet?

Add a Comment Cancel reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!