Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Created November 30, 2016 21:14
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 thomasplevy/655ffeaba9d027893a0ccf57508da063 to your computer and use it in GitHub Desktop.
Save thomasplevy/655ffeaba9d027893a0ccf57508da063 to your computer and use it in GitHub Desktop.
<?php // don't add this to your functions.php file
/**
* Do something cool when user is removed from a course
* @param int $student_id WP User ID
* @param int $course_id WP Post ID of the course
* @return void
*/
function my_unenrollment_acton( $student_id, $course_id ) {
// add a usermeta value that the student used to be in this course
$past = get_user_meta( $student_id, 'past_courses', true );
if ( ! $past ) {
$past = array();
}
array_push( $past, $course_id );
update_user_meta( $student_id, 'past_courses', $past );
}
add_action( 'llms_user_removed_from_course', 'my_unenrollment_acton', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment