• 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.