Differentiate between auto search and manual search
-
In
class-frontend.php
, thestore_search
method fires thewpsl_store_search
action. I’m working on an integration for the WordPress plugin Independent Analytics and started using this hook to track form submissions.While this hook fires for manual searches, I also noticed that it fires for those automatic searches that trigger on page load.
I was hoping to get a new argument added to the hook to allow us to differentiate between the two. Something like this works real well in testing:
// Before
do_action( 'wpsl_store_search' );
// After
$is_autoloaded = isset( $_GET['autoload'] ) && $_GET['autoload'];
do_action( 'wpsl_store_search', $is_autoloaded );Another option could be firing different hooks based on what happened:
// Before
do_action( 'wpsl_store_search' );
// After
$is_autoloaded = isset( $_GET['autoload'] ) && $_GET['autoload'];
do_action( $is_autoloaded ? 'wpsl_store_search_autoload' : 'wpsl_store_search' );Thanks for considering the request. Let me know what you think!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.