I'm trying to write a function that will 'grab'
the search term entered into the blog search form,
and then hook the function to the get_search_query
filter
like this add_filter('get_search_query','myFunction');
so that
everytime a search is made, 'myFunction' runs and grabs the search term
(or so I think), I have this line in myFunction to grab the search term
$search_term = get_search_query();
but it seems to be causing problem, the blog doesn't display, except I comment that particular line out. What is the right way to achieve the subject. Thanks.
Here is the code:
function myFunction(){
global $wpdb;
$search_term = get_search_query();
$table = $wpdb->prefix . "tableName";
$insert = "INSERT into $table(`serach_term`) VALUES ('$search_term')";
$wpdb->query($insert);
}
add_filter('get_search_query','myFunction');