The other option I’ve been toying with is creating the State values: as Idaho_state ( more specific search term )
Then display state as “Idaho” ( in the profile ) with some php:
if value “Idaho – ID”
echo “Idaho”
i’m looking for the same things to do with my site.
did you find a solution for that?
I’d approach this a different way –
something like:
`
$match_ids = $wpdb->get_var( “SELECT user_id FROM wp_bp_xprofile_data WHERE field_id = [whatever the field_id is for State] AND value = [whatever value you want to find] “);
`
$match_ids will be a simple array.
So loop thru the array and create a comma separated string out of the ids.
Then pass the string to bp_has_members() using ‘include’
something like
`
//$get_these_members is the id string you created
$get_these_members = ‘include=’ . substr($get_these_members, 0, -1); //trim the last comma
if ( bp_has_members( $get_these_members ) )
`
That way you could search for any value on any profile field.
Your approach might work, but… yikes.
https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-members-loop/
Ok where do you put the code and how can we make it for role.
Hey Thanks @shanebp
I’ll give that a try…
hi thanks @shanebp i am really biggner for my self i did what you said but matter is when i tried but never got result kindly check my code tell me i already spend 4 days.
<?php
global $wpdb, $bp;
$result = $wpdb->get_results(“SELECT user_id FROM wp_bp_xprofile_data WHERE value = ‘$_POST[language]’ OR value = ‘$_POST[budget]’ OR value = ‘$_POST[style]’LIMIT 0 , 30”);
print_r($result);
$result = array();
//$values = maybe_unserialize($result);
//echo var_dump( maybe_unserialize( $result ) );
//$values = $result;
//$value = bp_unserialize_profile_user_id( $values );
//$values = implode( “, “, $value);
//echo $values;
//print_r($values);
//so you have to ‘manually’ unserialize them
foreach($result as $user_id=>%d)
{
echo “Key=” . $user_id . “, Value=” . %d;
echo “<br>”;
}
//$values_str = implode( ‘,’, $getty );
//print_r($values_str);
//)
echo $get_these_members;
$get_these_members = ‘include=’ . substr($get_these_members, 0, -1);
?>