Hi Herve,
I will be testing these on my install today and will get back to you with more details. It seems strange but there may be some issue.Thank you
BrajeshHello Brajesh,
Sorry to come back to you
The next program that you have finished does not work anymore.
I think it comes (the author of the theme confirmed me) of the new BP template
It seems that it comes from the query which is not the same anymore.
The following function is used to “match” the list of people on the BP members page that matches its criteria in the xprofile fields.Ex .: see men if we have as a criterion “research man” …
Now I see only 3 profiles while I see the pagination that tells me for example 12 on … x pages. I filter at the same time the members who have an image rated> = 3.
Have a good day
Can you do something?****
/* filtrer les membres, début */ add_action( 'bp_pre_user_query_construct', 'membres_filtre_membre_selon_choix', 0 ); function membres_filtre_membre_selon_choix( $query ) { if ( ! is_user_logged_in() ) { return; } $user_id = get_current_user_id(); $field_jesuis = '57'; $field_jerecherche = '60'; $recherche_de = xprofile_get_field_data( $field_jerecherche, $user_id ); //$recherche_de = xprofile_get_field_data( 'Je recherche', $user_id, 'comma' ); if ( empty( $recherche_de ) ) { return; } if ( bp_is_user_friends() ) { return;// non appliqué si page amis (ne filtre pas sur la page des amis. Ce sera problématique car il ne filtrera pas le widget / shortcode sur la page des amis). } $xprofile_query = isset( $query->query_vars['xprofile_query'] ) ? $query->query_vars['xprofile_query'] : array(); $xprofile_query[] = array( 'field' => $field_jesuis, 'value' => $recherche_de, 'compare' => '=', ); if ( bp_is_members_directory() ) { //photo_priorite $xprofile_query[] = array( 'field' => 'photo_note', 'value' => 3, 'compare' => '>=', 'type' => 'NUMERIC', ); } if ( ! empty( $xprofile_query ) ) { $query->query_vars['xprofile_query'] = $xprofile_query; } return $query; } /* filtrer les membres, fin */
Hi Herve,
The above code is correct and It will work with current BuddyPress unless you have changed the field ids or some other code is interfering with it.Also, if you are using BP Nouveau template pack, It can affect the above query(The Nouveau template also filters on ‘bp_pre_user_query_construct’ and ” ).
My suggestion will be to switch to BP Legacy and try.
Regards
Brajeshhello Brajesh,
I still spent hours but I do not understand where the problem comes from.
I asked the help of the author of the theme who does not want to go further. He advised me to debug to do1 / query used by the Woffice template.
$ members_loop_query = apply_filters (‘woffice_members_loop_query’, http_build_query ($ query_array));
fw_print ($ members_loop_query);I get the result
type=active&action=active&page=1&exclude=0%2C1%2C3809%2C2749%2C3455%2C3927%2C2430%2C4016%2C3849%2C4133%2C3112%2C2586%2C3957%2C3898%2C1505%2C37 ... &per_page=12
2 / your code
fw_print ($ query);
return $ query;I get the result
BP LEGACYBP_User_Query ( [query_vars_raw] => array ( [type] => 'active' [user_id] => 0 [exclude] => '0,1,3809,2749,3455,3927,2430,4016,.......1378,4147' [search_terms] => false [meta_key] => false [meta_value] => false [member_type] => '' [member_type__in] => '' [member_type__not_in] => '' [include] => false [per_page] => 12 [page] => 1 [populate_extras] => true [count_total] => 'count_query' ) [query_vars] => array ( [type] => 'active' [per_page] => 12 [page] => 1 [user_id] => 0 [search_terms] => false [search_wildcard] => 'both' [include] => false [exclude] => '0,1,3809,2749,3455,3927,2430,4016,.....3617,2984,1641,3115,3669,852,791,3763,3506,3083,1496,1378,4147' [user_ids] => false [member_type] => '' [member_type__in] => '' [member_type__not_in] => '' [meta_key] => false [meta_value] => false [xprofile_query] => array ( [0] => array ( [field] => '57' [value] => 'Une Femme' [compare] => '=' ) [1] => array ( [field] => 'photo_note' [value] => 3 [compare] => '>=' [type] => 'NUMERIC' ) ) [populate_extras] => true [count_total] => 'count_query' ) [results] => array() [total_users] => 0 [user_ids] => array() [uid_clauses] => array() [uid_table] => '' [uid_name] => '' [*:no_results] => array ( [join] => '' [where] => '0 = 1' ) )
BP NOUVEAU
BP_User_Query ( [query_vars_raw] => array ( [type] => 'active' [user_id] => 0 [exclude] => '0,1,3809,2749,3455,3927,2430,4016,3849,4133,3112,....,791,3763,3506,3083,1496,1378,4147' [search_terms] => false [meta_key] => false [meta_value] => false [member_type] => '' [member_type__in] => '' [member_type__not_in] => '' [include] => false [per_page] => 12 [page] => 1 [populate_extras] => true [count_total] => 'count_query' ) [query_vars] => array ( [type] => 'active' [per_page] => 12 [page] => 1 [user_id] => 0 [search_terms] => false [search_wildcard] => 'both' [include] => false [exclude] => '0,1,3809,2749,3455,3927,2430,4016,3849,4133,3112,......3669,852,791,3763,3506,3083,1496,1378,4147' [user_ids] => false [member_type] => '' [member_type__in] => '' [member_type__not_in] => '' [meta_key] => false [meta_value] => false [xprofile_query] => array ( [0] => array ( [field] => '57' [value] => 'Une Femme' [compare] => '=' ) [1] => array ( [field] => 'photo_note' [value] => 3 [compare] => '>=' [type] => 'NUMERIC' ) ) [populate_extras] => true [count_total] => 'count_query' ) [results] => array() [total_users] => 0 [user_ids] => array() [uid_clauses] => array() [uid_table] => '' [uid_name] => '' [*:no_results] => array ( [join] => '' [where] => '0 = 1' ) )
When I switch to BP legacy, it does not change anything.
I removed the exclude no results so as not to take too many places
Do you have an idea to fix because I am obliged to use the new version of template woffice and buddypress!Regards
Hi Herve,
I am sorry but I can not do much with it.My suggestion will be to avoid using Nouveau for now if you want to use the above code.
As far as your Theme is concerned, it should work with both the template packs. BP Nouveau is neither an updated version of BP Legacy nor the BP Legacy is being deprecated.
These are two options as as far as BuddyPress is concerned, you will be fine using any of these. In other words, you can keep using BP Legacy.
Regards
Brajesh
The topic ‘filter the buddypress members in the list of members’ is closed to new replies.