Solved

Show a count of registered users in Drupal 7

Posted on 2014-10-30
2
37 Views
Last Modified: 2016-05-25
Hello
I want to display a count of approved users in a Drupal 7 site. I'm using PHP to do this.
I have the following
<?php $members = db_query("SELECT count(uid) FROM {users}")->fetchField(); echo "$members"; ?> 

Open in new window

This is giving me all members, approved or not. How do I show only the members that have been approved for membership?

Thank you
0
Comment
Question by:itkadmin
2 Comments
 
LVL 13

Accepted Solution

by:
Arrow_1 earned 500 total points
ID: 40414221
This will give you the active users:
<?php
$members = db_query("SELECT count(uid) FROM {users} WHERE status > 0")->fetchField();
echo "There are $members active users";
?>

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question