• Resolved rajuisk

    (@rajuisk)


    Hello team,

    I need help to filter user profiles on the basis of an age range field which will be applied on some of the age fields.

    In the user profile there are some age fields like

    child1_age
    child3_age
    child3_age
    child4_age
    child5_age

    an in bps search form i just want only one field age range and it should filter all the users matching the any age of above.Jut to inform you a user is also having other xprofile fields.

    The page I need help with: https://www.youngunitedparents.org/connect-with-the-community/members

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hello rajuisk,

    You need the field IDs of your fields, let’s say they are:

    child1_age ID 4
    child2_age ID 7
    child3_age ID 9
    child4_age ID 12
    child5_age ID 15

    When you build your search form, select the first field only (child1_age), then add this code to your bp-custom.php:

    add_filter ('bps_field_sql', 'change_query', 10, 2);
    function change_query ($sql, $f)
    {
    	if ($f->code == 'field_4')   // replace with actual first ID
    	{
    		$sql['where']['field_id'] = 'field_id IN (4, 7, 9, 12, 15)';   // replace with actual ID list
    	}
    	return $sql;
    }

    Does it work now as expected?

    Thread Starter rajuisk

    (@rajuisk)

    @dontdream Where should We put bp-custom.php
    I guess wp-content/plugins right?

    • This reply was modified 2 years, 9 months ago by rajuisk.
    Plugin Author Andrea Tarantini

    (@dontdream)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to apply an Age field on multiple xprofile field’ is closed to new replies.