How To Search Memberlist Profile Fields Via A URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    How To Search Memberlist Profile Fields Via A URL

    This is the search form in question:

    http://www.yoursite.com/forum/memberlist.php?do=search

    If the profile field is present on this search page, then you can search for it with a URL. You can submit a search to this form by loading a URL like this:

    http://www.yoursite.com/forum/memberlist.php?do=getall<field list>

    Where <field list> is a list of search criteria in the format specified below.

    Building A <field list>
    For each search option you need to add this onto the URL:

    &fieldname=value

    There are six different kinds of profile fields you can search for:

    Single-Line Text Box:
    These profile fields look like this in the source code:

    Code:
    <div class="fieldset">
    	NAME:<br />
    	<input type="text" class="bginput" name="[color=red]fieldX[/color]" value="" size="#" maxlength="#" />
    </div>
    Where fieldX is the field identifier of the profile field as shown in your:

    Admin CP -> User Profile Fields -> User Profile Field Manager

    You need to specify the text value in the URL. For example, if the field identifier is field2 and you want to search for the word vbulletin, then the <field list> would look like this:

    &field2=vbulletin

    Multiple-Line Text Box:
    These profile fields look like this in the source code:

    Code:
    <div class="fieldset">
    	NAME:<br />
    	<input type="text" class="bginput" name="[color=red]fieldX[/color]" value="" size="#" maxlength="#" />
    </div>
    Where fieldX is the field identifier of the profile field as shown in your:

    Admin CP -> User Profile Fields -> User Profile Field Manager

    You need to specify the text value in the URL. For example, if the field identifier is field2 and you want to search for the word vbulletin, then the <field list> would look like this:

    &field2=vbulletin

    Single-Selection Radio Buttons:
    These profile fields look like this in the source code:

    Code:
    <div class="fieldset">
    	NAME:<br />
    	<label for="rb_cpf_[color=red]fieldX[/color]_[color=blue]1[/color]"><input type="radio" name="userfield[[color=red]fieldX[/color]]" value="[color=blue]1[/color]" id="rb_cpf_[color=red]fieldX[/color]_[color=blue]1[/color]"  />OPTION 1</label> &nbsp;
    	<label for="rb_cpf_[color=red]fieldX[/color]_[color=blue]2[/color]"><input type="radio" name="userfield[[color=red]fieldX[/color]]" value="[color=blue]2[/color]" id="rb_cpf_[color=red]fieldX[/color]_[color=blue]2[/color]"  />OPTION 2</label> &nbsp;
    	<label for="rb_cpf_[color=red]fieldX[/color]_[color=blue]3[/color]"><input type="radio" name="userfield[[color=red]fieldX[/color]]" value="[color=blue]3[/color]" id="rb_cpf_[color=red]fieldX[/color]_[color=blue]3[/color]"  />OPTION 3</label> &nbsp;
    	<label for="rb_cpf_[color=red]fieldX[/color]_[color=blue]4[/color]"><input type="radio" name="userfield[[color=red]fieldX[/color]]" value="[color=blue]4[/color]" id="rb_cpf_[color=red]fieldX[/color]_[color=blue]4[/color]"  />OPTION 4</label> &nbsp;
    </div>
    Where fieldX is the field identifier of the profile field as shown in your:

    Admin CP -> User Profile Fields -> User Profile Field Manager

    You need to specify the corresponding option number in the URL. For example, if the field identifier is field2 and you want to search for the third option (number 3), then the <field list> would look like this:

    &field2=3

    Single-Selection Menu:
    These profile fields look like this in the source code:

    Code:
    <div class="fieldset">
    	NAME:<br />
    	<select name="[color=red]fieldX[/color]" id="csel_[color=red]fieldX[/color]">
    		<option value="[color=blue]0[/color]" selected="selected"></option>
    		<option value="[color=blue]1[/color]" >OPTION 1</option>
    		<option value="[color=blue]2[/color]" >OPTION 2</option>
    		<option value="[color=blue]3[/color]" >OPTION 3</option>
    		<option value="[color=blue]4[/color]" >OPTION 4</option>
    	</select>
    </div>
    Where fieldX is the field identifier of the profile field as shown in your:

    Admin CP -> User Profile Fields -> User Profile Field Manager

    You need to specify the corresponding option number in the URL. For example, if the field identifier is field2 and you want to search for the third option (number 3), then the <field list> would look like this:

    &field2=3

    Multiple-Selection Menu:
    These profile fields look like this in the source code:

    Code:
    <div class="fieldset">
    	NAME:<br />
    	<select name="[color=red]fieldX[/color][]" id="csel_[color=red]fieldX[/color]" size="0" multiple="multiple">
    		<option value="[color=blue]1[/color]" >OPTION 1</option>
    		<option value="[color=blue]2[/color]" >OPTION 2</option>
    		<option value="[color=blue]3[/color]" >OPTION 3</option>
    		<option value="[color=blue]4[/color]" >OPTION 4</option>
    	</select>
    </div>
    Where fieldX is the field identifier of the profile field as shown in your:

    Admin CP -> User Profile Fields -> User Profile Field Manager

    You need to specify the corresponding option number in the URL. For example, if the field identifier is field2 and you want to search for the third option (number 3), then the <field list> would look like this:

    &field2[]=3

    You can chain this together multiple times to search for multiple options since this is a multiple-selection menu. For example, to search for users with option 3 and 4 selected, use this:

    &field2[]=3&field2[]=4

    Multiple-Selection Checkbox:
    These profile fields look like this in the source code:

    Code:
    <div class="fieldset">
    	NAME:<br />
    	<label for="cb_cpf_[color=red]fieldX[/color]_[color=blue]1[/color]"><input type="checkbox" name="userfield[[color=red]fieldX[/color]][]" value="[color=blue]1[/color]" id="cb_cpf_[color=red]fieldX[/color]_[color=blue]1[/color]"  />OPTION 1</label> &nbsp;
    	<label for="cb_cpf_[color=red]fieldX[/color]_[color=blue]2[/color]"><input type="checkbox" name="userfield[[color=red]fieldX[/color]][]" value="[color=blue]2[/color]" id="cb_cpf_[color=red]fieldX[/color]_[color=blue]2[/color]"  />OPTION 2</label> &nbsp;
    	<label for="cb_cpf_[color=red]fieldX[/color]_[color=blue]3[/color]"><input type="checkbox" name="userfield[[color=red]fieldX[/color]][]" value="[color=blue]3[/color]" id="cb_cpf_[color=red]fieldX[/color]_[color=blue]3[/color]"  />OPTION 3</label> &nbsp;
    	<label for="cb_cpf_[color=red]fieldX[/color]_[color=blue]4[/color]"><input type="checkbox" name="userfield[[color=red]fieldX[/color]][]" value="[color=blue]4[/color]" id="cb_cpf_[color=red]fieldX[/color]_[color=blue]4[/color]"  />OPTION 4</label> &nbsp;
    </div>
    Where fieldX is the field identifier of the profile field as shown in your:

    Admin CP -> User Profile Fields -> User Profile Field Manager

    You need to specify the corresponding option number in the URL. For example, if the field identifier is field2 and you want to search for the third option (number 3), then the <field list> would look like this:

    &field2[]=3

    You can chain this together multiple times to search for multiple options since this is a multiple-selection menu. For example, to search for users with option 3 and 4 selected, use this:

    &field2[]=3&field2[]=4

    Searching Multiple Profile Fields At Once
    Just take the examples above and string them together. For example, this URL will search for members matching all of 3 different profile fields:

    http://www.yoursite.com/forum/memberlist.php?do=getall&field2=vbulletin&field6=3&field5[]=4
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...