Created
May 22, 2020 04:39
-
-
Save MrVibe/a6aeb90ecceccbf56d270c792857fd85 to your computer and use it in GitHub Desktop.
Add groundhogg tag
This file contains 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
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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure $contact = \Groundhogg\Plugin::$instance->tracking->get_current_contact() what this line does.