trying to pass the values of a select option to change the search term of members in Bp.

so far I can print the value with “echo” but i cannot set the search term depending on my option selected.

Printing the option works fine:

<form method="post">
<select name="category">
  <option value="" selected>All</option>
  <option value="Design and print">Design and Print</option>
  <option value="Food & Drink">Food & Drink</option>
  <option value="market">Market</option>
    <button type="submit" value="execute">SEARCH</button>     
<h5><?php echo $_POST['category']; ?></h5>

When I want to send the value as a string in the search term I cannot figure out the right code.

here what I have:

<?php if ( bp_has_members( 'search_terms=$_POST['category']') ) : ?>        
<?php while ( bp_members() ) : bp_the_member(); ?> 

however, the search not work as if i write ‘search_terms=Food & Drink’ for example

Read more here: HTML select value to PHP bp_has_members( ‘search_terms=??)


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: