Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Last active September 24, 2015 12:15
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/cd67c4965dc1caf8e87a to your computer and use it in GitHub Desktop.
Save MrVibe/cd67c4965dc1caf8e87a to your computer and use it in GitHub Desktop.
Enable/Disable Certificate & Badge on Course assignment by checking Student's Membership level
<?php
add_filter('wplms_course_student_certificate_check','check_user_membership_level',10,5); // Remove this if not required for Certificates
add_filter('wplms_course_student_badge_check','check_user_membership_level',10,5); // Remove this if not required for Badges
function check_user_membership_level($flag,$course_id,$user_id,$student_score,$awadrding_score){
$membership_ids = array(3); // You need to know the Membership ID or ID's (array(3,4)) in which you want to award certificate/badge to user
// Assuming 3 is the membership ID of the user in which we can award certificates/badges to the user
if(function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel($membership_ids,$user_id)){
return 1; // Continue with Certificate awarding process
}else{
return 0; // Disable Certificate awarding process
}
return $flag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment