WPCW_USERENROLLED::wpcw_user_enrolled( $user_id,  $courses_enrolled )

Validation function when the trigger action is hit


Parameters Parameters

$user_id

(Required)

$courses_enrolled

(Required) AssociatedParentData


Source Source

File: src/integrations/wp-courseware/triggers/wpcw-userenrolled.php

	public function wpcw_user_enrolled( $user_id, $courses_enrolled ) {

		if ( empty( $user_id ) ) {
			return;
		}



		foreach ( $courses_enrolled as $course_key ) {

			$course_detail = WPCW_courses_getCourseDetails( $course_key );

			$args = [
				'code'         => $this->trigger_code,
				'meta'         => $this->trigger_meta,
				'post_id'      => intval( $course_detail->course_post_id ),
				'user_id'      => $user_id,
				'is_signed_in' => true,
			];

			Automator()->maybe_add_trigger_entry( $args );
		}
	}