Last active
April 8, 2021 04:13
-
-
Save KaineLabs/d055b1d0378da6e93da2f1d2cacc2069 to your computer and use it in GitHub Desktop.
Set Default Members Directory Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Select Alphabet on Select Box. | |
*/ | |
function yzc_make_alphabet_selected() { | |
if ( ! bp_is_members_directory() ) { | |
return; | |
} | |
?> | |
<script type="text/javascript"> | |
jQuery( '#members-order-by option[value="alphabetical"]' ).attr( 'selected', true ); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'yzc_make_alphabet_selected' ); | |
/** | |
* Members Directory - Set Default Filter. | |
*/ | |
function yzc_set_default_members_directory_filter( $loop ) { | |
if ( bp_is_members_directory() && ! isset( $loop['scope'] ) ) { | |
$loop['type'] = 'alphabetical'; | |
} | |
return $loop; | |
} | |
add_filter( 'bp_after_has_members_parse_args', 'yzc_set_default_members_directory_filter', 9999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment