Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How do you list all of the values in a profile field?


TheEasyButton
Participant

@theeasybutton

I apologize for not coming back sooner to say this is solved. Been having lots of computer issues. The reason the other code didn’t work was we were reading from the wrong table. Another table had the info we needed so I swapped it out and here’s what I’m using now. Hopefully this will come in handy for a lot of people.

This goes in the head

<!-- drop down search -->
<SCRIPT LANGUAGE="JavaScript">
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
</SCRIPT>
<!-- end drop down search -->

And this goes in the body

<!-- drop down search -->
<form name="form">
<select name="site" size=1>
<option value="">Blah Blah</option>
<?php
$field_id = 2; // this should be the id of the
// field you want, see your wp_bp_xprofile_fields
// database table to find it

global $wpdb;

$sql = "SELECT name FROM {$wpdb->base_prefix}bp_xprofile_fields WHERE parent_id = {$field_id} ORDER BY id DESC";
$result = $wpdb->get_col($wpdb->prepare($sql));
foreach($result as $row){
if(strlen($row) > 0){
$values[$row]++;
}
}
foreach($values as $key => $value){
echo "<option value=\"members/?s=$key\">$key</option>";
}
?>
</select>
<input type=button value="Go!" onClick="javascript:formHandler(this)">
</form>
<!-- end drop down search -->

Don’t forget to change the number of the field. Thanks for all of your help =D

Skip to toolbar