Hi imborx,
You can add this code to your bp-custom.php:
add_action ('bps_field_before_search_form', 'set_defaults');
function set_defaults ($f)
{
if ($f->code == 'field_23') // replace 23 with your field ID
{
$f->value['distance'] = 200;
$f->value['units'] = 'km'; // 'km' or 'miles'
}
}
Thread Starter
imborx
(@imborx)
Thank you Andrea, but at least for me isn’t working (or I’m doing something wrong).
I tried to replace ‘field_23’ for my field ID (‘field_277’ and also ‘field_277_distance’ and ‘field_277_distance[distance]’). and any of them worked. I tried to add to bp-custom.php and also I tried the same removing that and adding to my theme functions.php and I still don’t see any difference. I keep seeing “1” in distance by default.
I removed cache after any change.
p.s. I attach you an screenshot to show you what I added: https://i.gyazo.com/1360a8123b7af779d6dbb17778cc5bf7.png
Thanks a lot!
The correct choice is field_277 replacing field_23.
If that doesn’t work, could you please specify BuddyPress version, active theme, location plugin used, BP Profile Search version, and form template? Also, copy and paste the template information from Users -> Profile Search, column Template.
Thread Starter
imborx
(@imborx)
Nevermind @dontdream
My bad, tt worked perfectly. It seems to be an issue with my current logged in sesion
Thanks a lot 🙂
No problem, glad you were able to fix it!