• Resolved justanotherwordpressuser

    (@justanotherwordpressuser)


    First off, thank you for a wonderful plugin. I have the age range on my search form displaying as a text field and I would like it to be a dropdown instead. Can you help me achieve this?

    Right now is is displaying as text box but instead of the min and max being next to one another, the min is on top and the max is below it with a hyphen in between the two. For me it looks kind of weird and I don’t know whether this is a theme issue or not.

    Either way, having a dropdown instead would really work for me.

    Note: I have the latest version of your plugin as of today and I am using the Enfold Theme.

    I apologize if someone has already asked this question before and I missed it. I browsed through the support forum (all 10 pages) and I did not see it posted anywhere.

    Thank you in advance and keep up the good work.

    https://wordpress.org/plugins/bp-profile-search/

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

    (@dontdream)

    Hi justanotherwordpressuser,

    Welcome on the forum!

    You can display the age range fields as two drop down lists, using the template bps-form-sample-1.

    Sometimes a template doesn’t work well with a specific theme, because it’s not possible to write templates that fit every theme.

    In these cases you can modify your templates to suit your theme, possibly with the help of the theme authors. After you modify a template, it’s best to move it to the directory buddypress/members under your theme directory.

    Thread Starter justanotherwordpressuser

    (@justanotherwordpressuser)

    You’re right, it used to display as dropdown on bps-form-sample-1 but ever since the newest update, I can’t get it to display it. I’ve cleared my cache and nothing still. Your previous version was showing it just fine.

    Plugin Author Andrea Tarantini

    (@dontdream)

    Please make sure you are selecting the form template in the right place :), i.e. if your form is in a widget, select the template in the widget settings, if it’s in a shortcode, select the template in the shortcode, and only if it’s in a directory page you can select the template in the ‘Add to Directory’ metabox.

    Often I make that mistake myself, when I try to change a widget’s template using the ‘Add to Directory’ metabox…

    Thread Starter justanotherwordpressuser

    (@justanotherwordpressuser)

    Hey Andrea,
    Thanks for your effort to solve this but I have not gotten it right with the date range. Here is the code I have.

    By the way, I’m no expert on php but I have tried everything from clearing my cache to reinstalling and nothing happens.

    Let me know how to set a dropdown date format. Can this be added as an option on your plugin?
    There is another glitch too. The date range field is not only limited to numbers only so, people can mistakenly input letters and any other type of character.

    Thanks again, I really appreciate it.

    <?php
    
    /*
     * BP Profile Search - form template 'bps-form-sample-1'
     *
     * See http://dontdream.it/bp-profile-search/form-templates/ if you wish to modify this template or develop a new one.
     *
     */
    
    	$F = bps_escaped_form_data ();
    
    	$toggle_id = 'bps_toggle'. $F->id;
    	$form_id = 'bps_'. $F->location. $F->id;
    
    	if ($F->location != 'directory')
    	{
    		$action = $F->action;
    		echo "<div id='buddypress'>";
    	}
    	else
    	{
    		$action = parse_url ($_SERVER['REQUEST_URI'], PHP_URL_PATH);
    ?>
    	<div class="item-list-tabs bps_header">
    	  <ul>
    		<li><?php echo $F->header; ?></li>
    <?php
    		if ($F->toggle)
    		{
    ?>
    		<li class="last">
    		  <input id="<?php echo $toggle_id; ?>" type="submit" value="<?php echo $F->toggle_text; ?>">
    		</li>
    		<script type="text/javascript">
    			jQuery(document).ready(function($) {
    				$('#<?php echo $form_id; ?>').hide();
    				$('#<?php echo $toggle_id; ?>').click(function(){
    					$('#<?php echo $form_id; ?>').toggle();
    				});
    			});
    		</script>
    <?php
    		}
    ?>
    	  </ul>
    	</div>
    <?php
    	}
    
    	echo "<form action='$action' method='$F->method' id='$form_id' class='standard-form'>\n";
    
    	$j = 0;
    	foreach ($F->fields as $f)
    	{
    		if ($f->display == 'hidden')
    		{
    			echo "<input type='hidden' name='$f->code' value='$f->value'>\n";
    			continue;
    		}
    
    		$name = sanitize_title ($f->name);
    		$alt = ($j++ % 2)? 'alt': '';
    		$class = "editfield field_$f->id field_$name $alt";
    
    		echo "<div class='$class'>\n";
    
    		switch ($f->display)
    		{
    		case 'range':
    			if ($f->type == 'datebox')
    			{
    				echo "<label for='$f->code'>$f->label</label>\n";
    
    				echo "from <select name='{$f->code}_min' id='$f->code'>\n";
    				echo "<option  value=''>min</option>\n";
    				for ($k=18; $k<100; $k++)
    				{
    					$selected = ($k == $f->min)? "selected='selected'": "";
    					echo "<option $selected value='$k'>$k</option>\n";
    				}
    				echo "</select>\n";
    
    				echo " to <select name='{$f->code}_max'>\n";
    				echo "<option  value=''>max</option>\n";
    				for ($k=18; $k<100; $k++)
    				{
    					$selected = ($k == $f->max)? "selected='selected'": "";
    					echo "<option $selected value='$k'>$k</option>\n";
    				}
    				echo "</select>\n";
    
    				break;
    			}
    			echo "<label for='$f->code'>$f->label</label>\n";
    			echo "<input style='width: 10%;' type='text' name='{$f->code}_min' id='$f->code' value='$f->min'>";
    			echo '&nbsp;-&nbsp;';
    			echo "<input style='width: 10%;' type='text' name='{$f->code}_max' value='$f->max'>\n";
    			break;
    
    		case 'textbox':
    			echo "<input type='text' name='$f->code' id='$f->code' placeholder='$f->label' value='$f->value'>\n";
    			break;
    
    		case 'number':
    			echo "<label for='$f->code'>$f->label</label>\n";
    			echo "<input type='number' name='$f->code' id='$f->code' value='$f->value'>\n";
    			break;
    
    		case 'url':
    			echo "<input type='text' inputmode='url' name='$f->code' id='$f->code' placeholder='$f->label' value='$f->value'>\n";
    			break;
    
    		case 'textarea':
    			echo "<label for='$f->code'>$f->label</label>\n";
    			echo "<textarea rows='5' cols='40' name='$f->code' id='$f->code'>$f->value</textarea>\n";
    			break;
    
    		case 'selectbox':
    			echo "<select name='$f->code' id='$f->code'>\n";
    
    			$no_selection = apply_filters ('bps_field_selectbox_no_selection', $f->label, $f);
    			if (is_string ($no_selection))
    				echo "<option  value=''>$no_selection</option>\n";
    
    			foreach ($f->options as $key => $label)
    			{
    				$selected = in_array ($key, $f->values)? "selected='selected'": "";
    				echo "<option $selected value='$key'>$label</option>\n";
    			}
    			echo "</select>\n";
    			break;
    
    		case 'multiselectbox':
    			echo "<label for='$f->code'>$f->label</label>\n";
    			echo "<select name='{$f->code}[]' id='$f->code' multiple='multiple'>\n";
    
    			foreach ($f->options as $key => $label)
    			{
    				$selected = in_array ($key, $f->values)? "selected='selected'": "";
    				echo "<option $selected value='$key'>$label</option>\n";
    			}
    			echo "</select>\n";
    			break;
    
    		case 'radio':
    			echo "<div class='radio'>\n";
    			echo "<span class='label'>$f->label</span>\n";
    			echo "<div id='$f->code'>\n";
    
    			foreach ($f->options as $key => $label)
    			{
    				$checked = in_array ($key, $f->values)? "checked='checked'": "";
    				echo "<label><input $checked type='radio' name='$f->code' value='$key'>$label</label>\n";
    			}
    			echo "</div>\n";
    			echo "<a class='clear-value' href='javascript:clear(\"$f->code\");'>". __('Clear', 'buddypress'). "</a>\n";
    			echo "</div>\n";
    			break;
    
    		case 'checkbox':
    			echo "<div class='checkbox'>\n";
    			echo "<span class='label'>$f->label</span>\n";
    
    			foreach ($f->options as $key => $label)
    			{
    				$checked = in_array ($key, $f->values)? "checked='checked'": "";
    				echo "<label><input $checked type='checkbox' name='{$f->code}[]' value='$key'>$label</label>\n";
    			}
    			echo "</div>\n";
    			break;
    
    		default:
    			echo "<p>BP Profile Search: don't know how to display the <em>$f->display</em> field type.</p>\n";
    			break;
    		}
    
    		if (!empty ($f->description) && $f->description != '-')
    			echo "<p class='description'>$f->description</p>\n";
    
    		echo "</div>\n";
    	}
    
    	echo "<div class='submit'>\n";
    	echo "<input type='submit' value='". __('Search', 'buddypress'). "'>\n";
    	echo "</div>\n";
    	echo "<input type='hidden' name='bp_profile_search' value='$F->id'>\n";
    	echo "</form>\n";
    
    	if ($F->location != 'directory')  echo "</div>\n";
    
    // BP Profile Search - end of template
    Plugin Author Andrea Tarantini

    (@dontdream)

    I assumed you were using a ‘datebox’ profile field for your age field, but probably you are using a ‘birthdate’ field created by the Buddypress Xprofile Custom Fields Type plugin. Is that right?

    Thread Starter justanotherwordpressuser

    (@justanotherwordpressuser)

    yes, thats correct. Should I switch to a datebox or can I accomplish that with a birthdate field?

    Thank you.

    Plugin Author Andrea Tarantini

    (@dontdream)

    There is a bug in the birthdate support introduced in BP Profile Search 4.5. I’m going to fix it as soon as possible, thank you for reporting!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Age range as dropdown instead of text input’ is closed to new replies.