This topic has 6 replies, 3 voices, and was last updated 6 years by Radu.

  • Author
  • #185269
     HDcms
    Participant

    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

    #185375
     HDcms
    Participant

    Hello,

    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 mixed

    COPY CODE
    add_filter( 'I'm looking for', 'my_custom_ids', 10, 2 );
    function my_custom_ids( $field_name, $field_value = '' ) {
    ...
    #185412
     Laura
    Moderator

    Hello, 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 solution

    Laura 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 🙂

    #185493
     HDcms
    Participant

    HI,
    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
    Regards

    #185587
     Radu
    Moderator

    Hi,

    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-posts

    Good luck

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #185590
     HDcms
    Participant

    Hi,
    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/
    Regards

    #185614
     Radu
    Moderator

    Cuz 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
Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?