-
Author
-
January 9, 2018 at 15:48 #185269HDcmsParticipant
Hello,
The idea is to display only the list of members who match with a search criterion “radio button” (or if possible checkbox) that inserted the logged in member in his profile (eg I am looking for a : developer=”buddypress” 🙂
I found the following function but how to add filter add_filter on the display of the list of members in bp-custom.php?
`function my_custom_ids( $field_name, $field_value = ” ) {if ( empty( $field_name ) )
return ”;global $wpdb;
$field_id = xprofile_get_field_id_from_name( $field_name );
if ( !empty( $field_id ) )
$query = “SELECT user_id FROM ” . $wpdb->prefix . “bp_xprofile_data WHERE field_id = ” . $field_id;
else
return ”;if ( $field_value != ” )
$query .= ” AND value LIKE ‘%” . $field_value . “%'”;
/*
LIKE is slow. If you’re sure the value has not been serialized, you can do this:
$query .= ” AND value = ‘” . $field_value . “‘”;
*/$custom_ids = $wpdb->get_col( $query );
if ( !empty( $custom_ids ) ) {
// convert the array to a csv string
$custom_ids_str = ‘include=’ . implode(“,”, $custom_ids);
return $custom_ids_str;
}
else
return ”;}`
https://codex.buddypress.org/developer/loops-reference/the-members-loop/
Regards
January 10, 2018 at 13:28 #185375HDcmsParticipantHello,
I put my search field “radio button”: “I’m looking for”
I am waiting for the display of the:
list of all the members who checked “H” if the member put “I search” = “H”
list of all members who checked “F” if the member put “I search” = “F”
Off right now, everything is mixedCOPY CODEadd_filter( 'I'm looking for', 'my_custom_ids', 10, 2 ); function my_custom_ids( $field_name, $field_value = '' ) { ...
January 10, 2018 at 18:25 #185412LauraModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
January 11, 2018 at 11:11 #185493HDcmsParticipantHI,
Ok tanks
I think I understand, it’s a bit more complicated. The simplest is to explain as for a dating site.
Filter the display of the list of members is done with a single criterion.
I display the criterion “I research” of my profile = the criterion “I am” of all the other profiles
RegardsJanuary 12, 2018 at 16:20 #185587RaduModeratorHi,
The member loops uses the bp_ajax_querystring function to build member results aslo this function has a filter with you can alterate the query, the filter it’s : bp_ajax_querystring / https://codex.buddypress.org/developer/function-examples/bp_ajax_querystring/
So there should be made a custom function/s that check it’s there it’s member directory and only then to run that function and also should be builded the logic of your flow.
Examples:
https://buddypress.trac.wordpress.org/ticket/5455
https://wordpress.stackexchange.com/questions/271023/buddypress-filter-members-based-on-if-they-have-postsGood luck
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJanuary 12, 2018 at 16:34 #185590HDcmsParticipantHi,
Ok thank you but I do not understand why you did not follow the track that I started!?
https://codex.buddypress.org/developer/loops-reference/the-members-loop/
RegardsJanuary 12, 2018 at 17:36 #185614RaduModeratorCuz from my point of view that’s the base way to manipulate the bp loop query
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.