public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Function called when the user completes a module.
 *
 * @since 1.0.0
 *
 * @param integer $userID The ID of the user that's completed the unit.
 * @param integer $unitID The ID of the unit that's just been completed.
 * @param object  $unitParentData The object of parent data associated with the unit, such as module and course.
 */
Function called when the user completes a module.

@param integer $userID The ID of the user that's completed the unit.
@param integer $unitID The ID of the unit that's just been completed.
@param object  $unitParentData The object of parent data associated with the unit, such as module and course.
Function called when the user completes a module . @param integer $userID The ID of the user that ' s completed the unit . @param integer $unitID The ID of the unit that ' s just been completed . @param object $unitParentData The object of parent data associated with the unit such as module and course .
function WPCW_actions_users_courseCompleted( $userID, $unitID, $unitParentData ) {
	if ( ! $userID || ! $unitID || ! $unitParentData ) {
		return;
	}
	if ( $unitParentData->course_opt_use_certificate == 'use_certs' ) {
		WPCW_certificate_generateCertificateEntry( $userID, $unitParentData->course_id );
	}
	$userHasUngradedQuestions = WPCW_quizzes_doesUserHaveAnyUngradedQuizzes( $userID, $unitParentData->course_id );
	$userDetails = get_userdata( $userID );
	$adminSubject = __( "Course Complete Notification - {USER_NAME} - '{COURSE_TITLE}'", 'wp-courseware' );
	$adminBody    = __( "Hi Trainer!
Just to let you know, {USER_NAME} has just completed the '{COURSE_TITLE}' course.
{SITE_NAME}
{SITE_URL}
", 'wp-courseware' );
	if ( $unitParentData->email_complete_course_option_admin == 'send_email' && $unitParentData->course_to_email && ! $userHasUngradedQuestions ) {
		WPCW_email_sendEmail( $unitParentData,
			$userDetails,
			$unitParentData->course_to_email,
			$adminSubject, $adminBody
		);
	}
	if ( $unitParentData->email_complete_course_option == 'send_email' && ! $userHasUngradedQuestions ) {
		do_action( 'wpcw_user_completed_module', $userID, $unitID, $unitParentData );
		WPCW_email_sendEmail( $unitParentData,
			$userDetails,                                    
			$userDetails->user_email,
			$unitParentData->email_complete_course_subject, 
			$unitParentData->email_complete_course_body        
		);
	}
		do_action( "wpcw_user_completed_course_notification", $unitParentData, $userDetails, $adminSubject, $adminBody );
}
function WPCW_actions_users_courseCompleted ( $ userID , $ unitID , $ unitParentData ) { if ( ! $ userID || ! $ unitID || ! $ unitParentData ) { return ; } if ( $ unitParentData -> course_opt_use_certificate == 'use_certs' ) { WPCW_certificate_generateCertificateEntry ( $ userID , $ unitParentData -> course_id ) ; } $ userHasUngradedQuestions = WPCW_quizzes_doesUserHaveAnyUngradedQuizzes ( $ userID , $ unitParentData -> course_id ) ; $ userDetails = get_userdata ( $ userID ) ; $ adminSubject = __ ( " Course Complete Notification - {USER_NAME} - '{COURSE_TITLE}' " , 'wp-courseware' ) ; $ adminBody = __ ( " Hi Trainer!

Just to let you know, {USER_NAME} has just completed the '{COURSE_TITLE}' course.

{SITE_NAME}
{SITE_URL}
 " , 'wp-courseware' ) ; if ( $ unitParentData -> email_complete_course_option_admin == 'send_email' && $ unitParentData -> course_to_email && ! $ userHasUngradedQuestions ) { WPCW_email_sendEmail ( $ unitParentData , $ userDetails , $ unitParentData -> course_to_email , $ adminSubject , $ adminBody ) ; } if ( $ unitParentData -> email_complete_course_option == 'send_email' && ! $ userHasUngradedQuestions ) { do_action ( 'wpcw_user_completed_module' , $ userID , $ unitID , $ unitParentData ) ; WPCW_email_sendEmail ( $ unitParentData , $ userDetails , $ userDetails -> user_email , $ unitParentData -> email_complete_course_subject , $ unitParentData -> email_complete_course_body ) ; } do_action ( " wpcw_user_completed_course_notification " , $ unitParentData , $ userDetails , $ adminSubject , $ adminBody ) ; }
Function called when the user completes a module.
Function called when the user completes a module .
// Certificates have been requested, so generate one for this user and course. // Add a certificate entry to the database for the user. // Admin wants an email notification, and email address exists. Assumption is that it's valid. // Check if admin wants user to have an email. // User who's done the completion // Use subject template in the settings // Use body template in the settings // Any additional admin-level notifications?
