OK i’ve come up with a solution but it feels dirty. Hoping someone can tell me if this approach is a bad one:
In header.php just above my search form I have
$standard_search_value = bp_get_search_default_text( 'members' );
$query_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $standard_search_value;
// globalise the search term or phrase variable so it can be used outside header.php
$GLOBALS['search_term_phrase'] = $query_value;
The in members-loop.php i can output the phrase when delivering results:
echo $GLOBALS['search_term_phrase'];
$_REQUEST[‘s’] isn’t available in members-loop after clicking ?
@shanebp I thought that too but it seems to be. Check out how BP remembers the search term after clicking. See bp_directory_members_search_form()
in bp-members-template.php
If it’s available, why assign it to a global in a different file ?
The use of a global is the only thing funky about what you’re doing.
Try just checking ‘s’ in members-loop.
echo $_REQUEST['s'];
in members-loop.php worked! The global was the bit I didn’t like. For some reason I completely overlooked the obvious. Thanks @shanebp for the solution.