This topic has 3 replies, 2 voices, and was last updated 10 years by Abe.

  • Author
  • #16168
     bayfest
    Participant

    If I want to modify the match/search algorithm, then this is the file I need to edit, correct?
    “wp-content\themes\sweetdate\custom_buddypress\kleo-bp-search.php”
    within this function: function bp_members_search($posted) { …. }

    I would like to match people based on some extended profile fields.
    here is an example for astrology:
    I am a “Capricorn” and I could match with someone who is “Taurus” or “Virgo” …
    Someone who is “Libra” would match with someone who is “Aquarius” or “Sagittarius” …

    I create an Extended Profile field for the user to choose one of the 12 signs as their star sign.
    … but how can I check for matches based on the logic from above (for example)?
    Thanks!

    #16345
     Abe
    Keymaster

    Hi, Right now you can just match fields with their same value based on this example: https://archived.seventhqueen.com/forums/topic/match-numbers

    If you want other logic then just copy function bp_members_search to your child theme/functions.php and change it to match your needs

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

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #16414
     bayfest
    Participant

    ah, thanks. So after reading that thread I came up with this (this is a example for the “I am a “Capricorn” and I could match with someone who is “Taurus” or “Virgo”” part):

    ————————-
    function compatibility_score($userid1=false, $userid2=false)
    {
    global $kleo_config;

    if ($userid1 && $userid2)
    {
    $score = 1;

    // Sex match
    if ((isset($kleo_config[‘matching_fields’][‘sex_match’]) && $kleo_config[‘matching_fields’][‘sex_match’] == ‘1’)
    || !isset($kleo_config[‘matching_fields’][‘sex_match’]) )
    {
    $field1_u1 = xprofile_get_field_data($kleo_config[‘matching_fields’][‘sex’], $userid1);
    $field12_u1 = xprofile_get_field_data($kleo_config[‘matching_fields’][‘looking_for’], $userid1);
    $field1_u2 = xprofile_get_field_data($kleo_config[‘matching_fields’][‘sex’], $userid2);
    $field12_u2 = xprofile_get_field_data($kleo_config[‘matching_fields’][‘looking_for’], $userid2);

    if ((strcmp($field1_u1, $field12_u2) == 0) && (strcmp($field12_u1, $field1_u2) == 0)) {
    $score += 49; }
    //if no sex match, return the score
    else {
    return $score;
    }
    }

    // Star matc

    $starsign_user1 = xprofile_get_field_data(‘Star Sign’,$userid1);
    $starsign_user2 = xprofile_get_field_data(‘Star Sign’,$userid2);

    if (
    ((strcmp($starsign_user1, “Capricorn”) == 0) && ((strcmp($starsign_user2, “Taurus”) == 0) || (strcmp($starsign_user2, “Virgo”) == 0))) ||
    ((strcmp($starsign_user2, “Capricorn”) == 0) && ((strcmp($starsign_user1, “Taurus”) == 0) || (strcmp($starsign_user1, “Virgo”) == 0)))
    ) {
    $score += 50;
    }

    if ($score > 100) {
    $score = 100;
    }

    return $score;
    }
    }
    ————————-

    Could I put this function in the child theme/functions.php and it would be all I need to change the matching algorithm? Does the system match based on the highest score?

    Thanks again!

    #16431
     Abe
    Keymaster

    Yes just copy the function in the child theme. The function return the percentage number, eq 100 so it is up to you how you customize the function. By default it increments the $score variable with each matching field found

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

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?