Title: Default range distance
Last modified: February 13, 2020

---

# Default range distance

 *  Resolved [imborx](https://wordpress.org/support/users/imborx/)
 * (@imborx)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/)
 * Hi,
 * I would like to know how can I set by default a distance like 200 km in the Location
   field: [https://i.gyazo.com/005ae345d361fd11e20ee934b1ebc3fc.png](https://i.gyazo.com/005ae345d361fd11e20ee934b1ebc3fc.png)
   but I don’t see the way to add it in the form: [https://i.gyazo.com/34f8f679e15ddac0eb03458ef58a4c98.png](https://i.gyazo.com/34f8f679e15ddac0eb03458ef58a4c98.png)
 * Actually the field ask the user to type a value, but if I could set a hight default
   value (100, 200, 500 km) would be perfect and I won’t disturb users to ask them
   to type.
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/#post-12435869)
 * 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](https://wordpress.org/support/users/imborx/)
 * (@imborx)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/#post-12436597)
 * 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](https://i.gyazo.com/1360a8123b7af779d6dbb17778cc5bf7.png)
 * Thanks a lot!
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/#post-12436778)
 * 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](https://wordpress.org/support/users/imborx/)
 * (@imborx)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/#post-12436812)
 * Nevermind [@dontdream](https://wordpress.org/support/users/dontdream/)
 * My bad, tt worked perfectly. It seems to be an issue with my current logged in
   sesion
 * Thanks a lot 🙂
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/#post-12437809)
 * No problem, glad you were able to fix it!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Default range distance’ is closed to new replies.

 * ![](https://ps.w.org/bp-profile-search/assets/icon.svg?rev=1568973)
 * [BP Profile Search](https://wordpress.org/plugins/bp-profile-search/)
 * [Support Threads](https://wordpress.org/support/plugin/bp-profile-search/)
 * [Active Topics](https://wordpress.org/support/plugin/bp-profile-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bp-profile-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bp-profile-search/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/default-range-distance/#post-12437809)
 * Status: resolved