total count of contributors (5 posts)

  1. edoublep
    Posted 7 years ago #

    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?


  2. Ogre
    Posted 7 years ago #

    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;

  3. macsoft3
    Posted 7 years ago #

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

  4. macsoft3
    Posted 7 years ago #

    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.

  5. macsoft3
    Posted 7 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic