Title: Range drop-down select code does not apply
Last modified: June 11, 2019

---

# Range drop-down select code does not apply

 *  [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/)
 * Hi Andrea, I have followed your instructions to modify the range display, by 
   adding this code to bp-custom.php, I also replaced the field number, but no action,
   the drop down doesn’t show.
 * Just to clarify, how do I find the correct corresponding field number; is it 
   the field number in the search field form, counting fields from the top, or the
   field number in the profile fields?
 * Does it work with age range as well?
 * Regards
    Carsten
 *     ```
       add_action ('bps_field_before_search_form', 'change_display');
       function change_display ($f)
       {
           if ($f->code == 'field_4' && $f->display == 'range')
           {
               $f->display = 'range-select';
               $range = range (18, 99);
               $f->options = array ('' => '') + array_combine ($range, $range);
           }
       }
       ```
   

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

 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11628419)
 * Hello Carsten,
 * You can see the field ID if you go to the _Users -> Profile Fields_ admin page,
   and use the field _Edit_ button.
 * If you click the button, you go to the _Edit Field_ page and you can see the 
   field ID contained in the URL. If you hover on the button with your mouse, you
   reveal the URL, and see the field ID, without actually going to the _Edit Field_
   page.
 * Please note that the code you are using only works with the _age range_ search
   mode, and with the _bps-form-default_ template.
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11629410)
 * Hi Andrea, hmmm, I can’t get it to work, just to be sure, the code should be 
   field_2389 like stated, not field_id=2389?
 * > [View post on imgur.com](https://imgur.com/F4B94z9)
 * > [View post on imgur.com](https://imgur.com/ORSk4lH)
 * I use the x-profile fields to/from type, one with age range and one only range.
   Is it possible to make it work with the range search mode as well?
 * Regards
    Carsten
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11630080)
 * Hi Carsten,
 * Probably you are not using the built-in _bps-form-default_ template. Could you
   please go to your _Users -> Profile Search_ admin page and paste whatever is 
   displayed under the _Template_ column?
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11630159)
 * Hi again, yes I am using the default template
 * > [View post on imgur.com](https://imgur.com/hXmpMwr)
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11630167)
 * Should it work on both age range and range, and, in this case, should I add the
   code snippet for both by duplicate this with each id?
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11630203)
 * These are my profile fields type with corresponding search mode
 * > [View post on imgur.com](https://imgur.com/1pK48Z8)
 * > [View post on imgur.com](https://imgur.com/JgPtUls)
 * > [View post on imgur.com](https://imgur.com/hHMBFDj)
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11630451)
 * Carsten,
 * Try using this code in _bp-custom.php_:
 *     ```
       add_action ('bps_field_before_search_form', 'change_display');
       function change_display ($f)
       {
       // for the "age range" search mode
       	if ($f->code == 'field_4' && $f->display == 'range')
       	{
       		$f->display = 'range-select';
       		$range = range (18, 99);
       		$f->options = array ('' => '') + array_combine ($range, $range);
       	}
   
       // for the "range" search mode
       	if ($f->code == 'field_235' && $f->display == 'integer-range')
       	{
       		$f->display = 'range-select';
       		$range = range (0, 100);
       		$f->options = array ('' => '') + array_combine ($range, $range);
       	}
       }
       ```
   
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11630497)
 * Thanks for the code, it worked with the range, but not the age range.
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [7 years ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11631347)
 * Could you add
 * `if ($f->code == 'field_xyz') print_r ($f);`
 * inside the function? Replace xyz with the ID of the field with the “age range”
   search mode.
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11639580)
 * Hi Andrea, thanks for the code, unfortunatlly it adds drop down to all fields,
   also the distance search fields.
 * Regards
    Carsten
 *     ```
       add_action ('bps_field_before_search_form', 'change_display');
       function change_display ($f)
       {
       // for the "age range" search mode
       	if ($f->code == 'field_2389' && $f->display == 'range')
       	if ($f->code == 'field_2389') print_r ($f);
       	{
       		$f->display = 'range-select';
       		$range = range (18, 99);
       		$f->options = array ('' => '') + array_combine ($range, $range);
       	}
   
       // for the "range" search mode
       	if ($f->code == 'field_2038' && $f->display == 'integer-range')
       	{
       		$f->display = 'range-select';
       		$range = range (140, 210);
       		$f->options = array ('' => '') + array_combine ($range, $range);
       	}
       }
       ```
   
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11640607)
 * Sorry, I forgot to specify that the new line of code should be the first in the
   function.
 * It should display some data useful for debugging.
 *  Thread Starter [Carsten Lund](https://wordpress.org/support/users/carsten-lund/)
 * (@carsten-lund)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11736282)
 * Hi Andrea, now all search fields are all two drop-down select boxes, but the 
   range display in the edit personal profile section is still two input boxes.
 * How do I changes these fields as well, to two drop-down select boxes, to match
   the search form?
 * Thanks
 * Best
    Carsten
 *  Plugin Author [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * (@dontdream)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11738917)
 * Hi Carsten,
 * Unfortunately BP Profile Search is unable to customize the _Edit Profile_ page.
 * If your field type is provided by a plugin, e.g. _BuddyPress Xprofile Custom 
   Field Types_, I suggest you ask them for advice.

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

The topic ‘Range drop-down select code does not apply’ 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/)

 * 13 replies
 * 2 participants
 * Last reply from: [Andrea Tarantini](https://wordpress.org/support/users/dontdream/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/range-drop-down-select-code-does-not-apply/#post-11738917)
 * Status: not resolved