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 JarrydLong/4df95adfae825197e725859cad8f0e7e to your computer and use it in GitHub Desktop.
Save JarrydLong/4df95adfae825197e725859cad8f0e7e to your computer and use it in GitHub Desktop.
<?php
/**
* This recipe will create the [pmpro_member_search] shortcode, allowing to you to search
* your member directory.
*
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function mypmpro_member_search(){
$url = 'https://mysite.com/member-directory'; //Change this line to the member directory URL
$ret = "";
if(isset($_REQUEST['limit'])){
$limit = intval($_REQUEST['limit']);
} else if(empty($limit)){
$limit = 15;
}
if( !empty( $_REQUEST['ps'] ) ){
$ps = stripslashes( esc_attr( $_REQUEST['ps'] ) );
} else {
$ps = '';
}
$ret .= '<form role="search" method="post" class="pmpro_member_directory_search search-form" action="'.$url.'">';
$ret .= '<label>';
$ret .= '<span class="screen-reader-text">'.__('Search for:','pmpromd').'</span>';
$ret .= '<input type="search" class="search-field" placeholder="'.__('Search Members','pmpromd').'" name="ps" value="'.$ps.'" title="'.__('Search Members','pmpromd').'" />';
$ret .= '<input type="hidden" name="limit" value="'.esc_attr($limit).'" />';
$ret .= '</label>';
$ret .= '<input type="submit" class="search-submit" value="'.__('Search Members','pmpromd').'">';
$ret .= '</form>';
return $ret;
}
add_shortcode( 'pmpro_member_search', 'mypmpro_member_search' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment