Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created August 17, 2017 18:01
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 bappi-d-great/7ba550e35f1b9250b24cfa383971b1f1 to your computer and use it in GitHub Desktop.
Save bappi-d-great/7ba550e35f1b9250b24cfa383971b1f1 to your computer and use it in GitHub Desktop.
Auto enroll to a course based on Membership - CoursePress2 and Membership2
<?php
add_action( 'ms_model_relationship_create_ms_relationship_before', 'ms_controller_member_assign_memberships_done_cb', 99, 4 );
function ms_controller_member_assign_memberships_done_cb( $membership_id, $user_id, $gateway_id, $move_from_id ) {
$course = array(
// 'membership_id' => 'course_id'
'1324' => 6656,
'9087' => 22345
);
CoursePress_Data_Course::enroll_student( $user_id, $course[$membership_id] );
}
@sweilems
Copy link

it doesnt work when i add same membership to tow courses, it enrolls only in one course for the same membership , any thoughts?

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