Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Created May 22, 2020 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrVibe/a6aeb90ecceccbf56d270c792857fd85 to your computer and use it in GitHub Desktop.
Save MrVibe/a6aeb90ecceccbf56d270c792857fd85 to your computer and use it in GitHub Desktop.
Add groundhogg tag
add_action( 'wplms_submit_course', 'add_a_tag_when_complete_course', 10, 2 );
function add_a_tag_when_complete_course( $course_id, $user_id )
{
if($course_id !== 1500)
return;
$tags_to_add = [ 'Course1Complete', 'Course2Prospect' ];
$contact = \Groundhogg\Plugin::$instance->tracking->get_current_contact();
if ( ! $contact ){
return;
}
$contact->apply_tag( $tags_to_add );
$user = get_user_by('id',$user_id);
$first_name = $user->first_name;
$email = $user->email;
$contact = new \Groundhogg\Contact( [
'first_name' => $first_name,
'email' => $email
] );
$contact->apply_tag( $tags_to_add );
}
@MrVibe
Copy link
Author

MrVibe commented May 22, 2020

Not sure $contact = \Groundhogg\Plugin::$instance->tracking->get_current_contact() what this line does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment