Is there a neat way to apply the code you provided to a certain form only? We’re using several forms in different parts of the website, I’m now wondering how do I change the behavior on per-form basis.
Yes, it is possible. The filter passes additional arguments as well, the second one is the search ID. So changing the filter and the function definition will do the trick:
The $search_id variable will no contain the source box ID.