Created
October 30, 2023 10:41
-
-
Save BhargavBhandari90/b6f9c0aa8b34fe28fb120e537e43976b to your computer and use it in GitHub Desktop.
Set custom field to Members Search form and get result by that
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 | |
function bb_bp_ps_before_search_form( $F ) { | |
$new = new stdClass(); | |
$new->display = 'selectbox'; | |
$new->code = 'age_from'; // to be removed | |
$new->html_name = 'age_from'; | |
$new->value = ''; | |
$new->unique_id = bp_ps_unique_id( 'age_from' ); | |
$new->id = 0; | |
$new->label = 'Age From'; | |
$new->options = array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, ); | |
$F->fields[] = $new; | |
} | |
add_action( 'bp_ps_before_search_form', 'bb_bp_ps_before_search_form' ); | |
function bb_bp_ps_field_sql( $sql, $f ) { | |
// Do custom query for age. | |
return $sql; | |
} | |
add_filter( 'bp_ps_field_sql', 'bb_bp_ps_field_sql', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment