Skip to content

Instantly share code, notes, and snippets.

@jack-arturo
Last active March 8, 2023 11:45
Show Gist options
  • Save jack-arturo/5e2c7c64012442e3b67e196a3bb14985 to your computer and use it in GitHub Desktop.
Save jack-arturo/5e2c7c64012442e3b67e196a3bb14985 to your computer and use it in GitHub Desktop.
Blocks incoming webhooks for a user for one minute after tags were applied to them (to prevent loopbacks)
<?php
/**
* Sets a transient to lock a user from receiving webhooks from the CRM for one minute
* after tags have been applied by WP Fusion.
*
* @param int $user_id The user ID.
*/
function wpf_lock_user( $user_id ) {
$contact_id = wpf_get_contact_id( $user_id );
set_transient( 'wpf_api_lock_' . $contact_id, 'update', MINUTE_IN_SECONDS );
}
add_action( 'wpf_tags_applied', 'wpf_lock_user' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment