Title: Count usermeta with same value
Last modified: August 20, 2016

---

# Count usermeta with same value

 *  [mauricenaef](https://wordpress.org/support/users/mauricenaef/)
 * (@mauricenaef)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/count-usermeta-with-same-value/)
 * I would like to display the the number of user with the same meta_value on the
   dashboard, and am kind of stuck that it doesn’t get all values.
 * So I’ve created a new usermeta which gets added to the database on registration
   with the meta key code.
 *     ```
       $myusers = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key='code' AND meta_value='codevalue'" ) );
       		echo '<tr class="first"><td>' . count($myusers) . '</td><td class="t posts">user with code: code1</td>';
       ```
   
 * I’m not sure if I can use get_metadata or have to dwell into the DB. When using
   this code I can already get the number of users per defined code, but I would
   like to loop thru and give all codes as follows
 * 5 users with code: xxx
    3 users with code: yyy etc..
 * Hopy anyone can help or steer me in the right direction…
    Thanks in advance and
   best regards
 * Marcel

The topic ‘Count usermeta with same value’ is closed to new replies.

## Tags

 * [count](https://wordpress.org/support/topic-tag/count/)
 * [usermeta](https://wordpress.org/support/topic-tag/usermeta/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [mauricenaef](https://wordpress.org/support/users/mauricenaef/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/count-usermeta-with-same-value/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
