Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author donmik

    (@atallos)

    I don’t know if there is an easy way to achieve this… I think you will need a custom query…

    Thread Starter NicoPagel

    (@nicopagel)

    I am not familiar with coding. Could you perhaps help me?

    Plugin Author donmik

    (@atallos)

    Hi,

    I believe something like this should be the way:

    function get_total_members($field_id, $field_value) {
        global $wpdb, $bp;
        $res = $wpdb->query($wpdb->prepare(
           'SELECT COUNT(*) FROM ' . $wpdb->prefix . $bp->table_prefix . 'bp_xprofile_data
            WHERE field_id = %s
            AND value = \'%s\'
            GROUP BY field_id
           ', $field_id, $field_value
        ));
    
        return $res;
    }

    You need to call this function with the field id and the field value you want to search. It will return the number of members having this value in this field.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show count of all users who have selected male in gender field’ is closed to new replies.