Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ultimate Member 2.1 - Add search & reset buttons in member directory
// fixed reset button not working
add_action("um_members_directory_head", "um_custom_members_directory_head", 10, 1);
function um_custom_members_directory_head($args)
// added JavaScript to clear the search bar, filters and remove those criteria from the URL as well
<script type="text/javascript">
function searchClear() {
var elements = [] ;
elements = document.getElementsByClassName("um-search-line");
for(var i=0; i<elements.length ; i++){
elements[i].value = "" ;
window.location.href = window.location.href.split('?')[0];
<div class="um-search-submit" style="margin:auto;width:50%;">
<div style="width: 40%;float:left;margin:10px;text-align:center;">
<a href="#" class="um-button um-do-search" ><?php _e("Search", "ultimate-member"); ?></a>
<div style="width: 40%;float:left;margin:10px;text-align:center;">
<!-- the JavaScript is invoked by the Reset button -->
<a href="javascript:;" onclick="searchClear()" class="um-button um-alt um-clear-filters-a"><?php _e("Reset", "ultimate-member"); ?></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment