Support » Developing with WordPress » total count of contributors

  • I apologize if this information is readily available, however I’ve searched and searched, just can’t find it.

    Does anyone know of a way of a command to return the total number of contributors at page load?


Viewing 4 replies - 1 through 4 (of 4 total)
  • A simple query will return the number of users. This example query does not take into account the user status or level:

    SELECT count(*) AS user_count FROM wp_users;

    That table doesn’t just contain contributors but also other roles including admins.

    If there were unique numbers assigned to users depending on their roles under ‘user_status,’ you could count the one for contributors. However, it seems that only ‘0’ appears on any role. It is possible that you can manually assign the same unique number to contributors. If you assign 5, for example, you can easily count the number by writing

    $sql = "SELECT * FROM wp_users WHERE user_status = 5;
    $contr_count = mysql_query($sql, MySQL connection);
    $num_contr = mysql_num_rows($contr_count);

    You have to connect the database at first, though.

    I learned PHP programming about 3 weeks ago to build a spam database. If I can do it, I’m sure you can do it, too. Good luck.

    You can draw role information from wp_usermeta. So it is possible to automatically calculate the number of contributors.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘total count of contributors’ is closed to new replies.