Skip to content

Instantly share code, notes, and snippets.

@tobeyadr
Created December 22, 2023 18:12
Show Gist options
  • Save tobeyadr/10953b5c5429b31a25fe9214e0a87396 to your computer and use it in GitHub Desktop.
Save tobeyadr/10953b5c5429b31a25fe9214e0a87396 to your computer and use it in GitHub Desktop.
An example of use the track_live_activity() function
<?php
add_action( 'favorites_post', 'track_activity_when_post_is_favorited' );
/**
* Tracks activity in Groundhogg when a user marks their post as favorite
*
* @param $post WP_Post
*
* @return void
*/
function track_activity_when_post_is_favorited( $post ) {
\Groundhogg\track_live_activity( 'favorite_post', [
'post_id' => $post->ID
] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment