User:Search template tag
The User:Search function behaves similar to the EE Search function, and allows you to create a front-end member search form for your users. When a search is performed, you are returned to a results page with a search ID string in the URL. That string identifies the specific search that was performed. The results page is controlled by the User:Results tag.
{exp:user:search} content {/exp:user:search}
Parameters
The following parameters are available for use:
error_page=
error_page="user/error_template"
This parameter allows you to bypass the EE message template for displaying errors, and instead show your own regular template with the error messages. Error template must follow guidelines of User Error Page.
form:attribute=
form:class="your_class"
This parameter allows you to control any form attribute for the form in your template. Simply replace attribute with an attribute name such as id, name, class, etc, and specify a value for that attribute. You can specify this parameter multiple times to control as many attributes as necessary. This would normally be done to control your form with Javascript or style it with CSS.
group_id=
group_id="5|6|9"
This parameter allows you to constrain the search to a set of member group ID's. For multiples, use pipe character.
return=
return="template_group/template"
This parameter specifies the return URL for the results page. This would be the template that has the User:Results template tag in it.
role_id=
role_id="5|6|9"
This parameter allows you to constrain the search to a set of member role ID's. For multiples, use pipe character.
secure_action=
secure_action="yes"
This parameter allows you to set the action on the form to have https://. Use for processing forms with SSL.
secure_return=
secure_return="yes"
This parameter allows you to set the return on the form to have https://. Use for processing forms with SSL.
skip_field=
skip_field="firstname|lastname|screen_name"
This parameter allows you to skip some fields from being search if you want them ignored by the search engine. For multiples, use pipe character.
Variables
The following variables are available for use:
keywords
{keywords}
This variable returns the keyword(s) that were searched upon previously. This would be used if you were using the User:Search function to search within search results.
Form Fields
The following form fields are available for use:
custom_member_field
<input type="text" name="your_custom_member_field" />
Searches can be based upon custom member fields. Use the short_name of the custom member field you'd like to be available for searching. If used with keywords field, this will provide additional filtering to the keywords search.
keywords
<input type="text" name="keywords" />
This field is the field in which the user would enter their search terms.
search_within_results
<label>
<input type="checkbox" name="search_within_results" value="yes" />
Search within results?
</label>
You can let users search within the set of results that were initially returned by providing yes to this field.
screen_name
<input type="text" name="screen_name" />
You can search specifically on Screen Names of your users. If used with keywords field, this will provide additional filtering to the keywords search.
username
<input type="text" name="username" />
You can search specifically on Usernames of your users. If used with keywords field, this will provide additional filtering to the keywords search.
Examples
The following is a basic example of how a user search form might look:
{exp:user:search
return="user/results"
}
<h2>Search Member List</h2>
<p>
<input type="text" name="keywords" />
<button type="submit">Search</button>
</p>
{/exp:user:search}
The following is how a more advanced search form might look:
{exp:user:search
return="user/results"
}
<h2>Search Member List</h2>
<p>Keywords: <input type="text" name="keywords" /></p>
<p>Location: <input type="text" name="location" /></p>
<p>Favorite Food: <input type="text" name="favorite_food" /></p>
<p><button type="submit">Search</button></p>
{/exp:user:search}