Created
June 6, 2025 08:45
-
-
Save xlplugins/aa4e2422b867ace024d2923679069af9 to your computer and use it in GitHub Desktop.
prevent_lead_event_on_specific_pages.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Controls tracking JavaScript output for optin pages | |
* | |
* Disables tracking JS by default and only enables it for specific optin page IDs. | |
* Used to selectively enable tracking on certain optin pages while keeping it disabled | |
* for all others. | |
* | |
* @since 2.0.0 | |
* @param bool $bool Whether to allow tracking JS output | |
* @return bool Modified boolean value | |
*/ | |
add_action('wffn_allow_op_tracking_js', function($bool){ | |
$bool = false; | |
if ( WFOPP_Core()->optin_pages->is_wfop_page() && in_array(WFOPP_Core()->optin_pages->get_optin_id(),['YOUR_OPTIN_PAGE_ID'])) { | |
$bool = true; | |
} | |
return $bool; | |
}); | |
/** | |
* Controls lead event tracking for optin form submissions | |
* | |
* Removes the lead event tracking action for all optin pages except specified IDs. | |
* Prevents tracking of form submissions on unwanted optin pages by removing the | |
* tracking callback before it executes. | |
* | |
* @since 2.0.0 | |
* @param mixed $optin_page The optin page object | |
*/ | |
add_action('wffn_optin_form_submit',function($optin_page){ | |
if ( WFOPP_Core()->optin_pages->is_wfop_page() && !in_array(WFOPP_Core()->optin_pages->get_optin_id(),['YOUR_OPTIN_PAGE_ID'])) { | |
remove_action( 'wffn_optin_form_submit', array( WFFN_Ecomm_Tracking_Optin::get_instance(), 'maybe_execute_lead_event_for_optin' ) ); | |
} | |
},-1,1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment