Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirenshah/0b86f59a8b0b8a2be3a308903229c95d to your computer and use it in GitHub Desktop.
Save hirenshah/0b86f59a8b0b8a2be3a308903229c95d to your computer and use it in GitHub Desktop.
Ultimate Member 2.1 - Add search & reset buttons in member directory
<?php
// 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];
}
</script>
<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>
<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>
</div>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment