Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public function get_fields() {
'label' => __( 'Select a Section', 'lifterlms' ),
),

'llms_certificate' => array(
'controller_value' => array( 'user_earned_certificate' ),
'id' => '_faux_engagement_trigger_post_llms_certificate',
'label' => __( 'Select a Certificate', 'lifterlms' ),
),

);

foreach ( $trigger_post_fields as $post_type => $data ) {
Expand Down Expand Up @@ -324,6 +330,10 @@ public function save( $post_id ) {
$var = 'track';
break;

case 'user_earned_certificate':
$var = 'llms_certificate';
break;

default:
$var = false;

Expand Down
7 changes: 6 additions & 1 deletion includes/class.llms.engagements.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private function get_engagements( $trigger_type, $related_post_id = '' ) {

$related_select = ', relation_meta.meta_value AS related_post_id';
$related_join = "LEFT JOIN $wpdb->postmeta AS relation_meta ON triggers.ID = relation_meta.post_id";
$related_where = $wpdb->prepare( "AND relation_meta.meta_key = '_llms_engagement_trigger_post' AND relation_meta.meta_value = %d", $related_post_id );
$related_where = $wpdb->prepare( "AND relation_meta.meta_key = '_llms_engagement_trigger_post' AND ( relation_meta.meta_value IS NULL OR relation_meta.meta_value = %d )", $related_post_id );

}

Expand Down Expand Up @@ -232,6 +232,7 @@ protected function get_trigger_hooks() {
'llms_rest_student_registered',
'llms_user_added_to_membership_level',
'llms_user_enrolled_in_course',
'llms_user_earned_certificate',
);

// If there are any actions registered to this deprecated hook, add it to the list.
Expand Down Expand Up @@ -443,6 +444,10 @@ private function parse_hook_find_trigger_type( $action, $related_post_id ) {
case 'lifterlms_product_purchased':
$trigger_type = str_replace( 'llms_', '', get_post_type( $related_post_id ) ) . '_purchased';
break;

case 'llms_user_earned_certificate':
$trigger_type = str_replace( 'llms_', '', $action );
break;
}

return $trigger_type;
Expand Down
27 changes: 14 additions & 13 deletions includes/llms.functions.core.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,20 +455,21 @@ function llms_get_engagement_triggers() {
return apply_filters(
'lifterlms_engagement_triggers',
array(
'user_registration' => __( 'Student creates a new account', 'lifterlms' ),
'access_plan_purchased' => __( 'Student Purchases an Access Plan', 'lifterlms' ),
'course_enrollment' => __( 'Student enrolls in a course', 'lifterlms' ),
'course_purchased' => __( 'Student purchases a course', 'lifterlms' ),
'course_completed' => __( 'Student completes a course', 'lifterlms' ),
'user_registration' => __( 'Student creates a new account', 'lifterlms' ),
'access_plan_purchased' => __( 'Student Purchases an Access Plan', 'lifterlms' ),
'course_enrollment' => __( 'Student enrolls in a course', 'lifterlms' ),
'course_purchased' => __( 'Student purchases a course', 'lifterlms' ),
'course_completed' => __( 'Student completes a course', 'lifterlms' ),
// 'days_since_login' => __( 'Days since user last logged in', 'lifterlms' ), // @todo.
'lesson_completed' => __( 'Student completes a lesson', 'lifterlms' ),
'quiz_completed' => __( 'Student completes a quiz', 'lifterlms' ),
'quiz_passed' => __( 'Student passes a quiz', 'lifterlms' ),
'quiz_failed' => __( 'Student fails a quiz', 'lifterlms' ),
'section_completed' => __( 'Student completes a section', 'lifterlms' ),
'course_track_completed' => __( 'Student completes a course track', 'lifterlms' ),
'membership_enrollment' => __( 'Student enrolls in a membership', 'lifterlms' ),
'membership_purchased' => __( 'Student purchases a membership', 'lifterlms' ),
'lesson_completed' => __( 'Student completes a lesson', 'lifterlms' ),
'quiz_completed' => __( 'Student completes a quiz', 'lifterlms' ),
'quiz_passed' => __( 'Student passes a quiz', 'lifterlms' ),
'quiz_failed' => __( 'Student fails a quiz', 'lifterlms' ),
'section_completed' => __( 'Student completes a section', 'lifterlms' ),
'course_track_completed' => __( 'Student completes a course track', 'lifterlms' ),
'membership_enrollment' => __( 'Student enrolls in a membership', 'lifterlms' ),
'membership_purchased' => __( 'Student purchases a membership', 'lifterlms' ),
'user_earned_certificate' => __( 'Student earns a certificate', 'lifterlms' ),
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function action_callback( $user_id = null, $certificate_id = null, $relat
$this->related_post_id = $related_post_id;

$this->send();

}

/**
Expand All @@ -80,7 +79,6 @@ protected function get_subscriber( $subscriber ) {
}

return $uid;

}

/**
Expand Down Expand Up @@ -113,27 +111,15 @@ protected function set_subscriber_options( $type ) {
$options[] = $this->get_subscriber_option_array( 'student', 'yes' );
break;

case 'email':
$options[] = $this->get_subscriber_option_array( 'student', 'no' );
$options[] = $this->get_subscriber_option_array( 'custom', 'no' );
break;

}

return $options;

}

/**
* Determine what types are supported
* Extending classes can override this function in order to add or remove support
* 3rd parties should add support via filter on $this->get_supported_types()
*
* @return array associative array, keys are the ID/db type, values should be translated display types
* @since 3.8.0
* @version 3.8.0
*/
protected function set_supported_types() {
return array(
'basic' => __( 'Basic', 'lifterlms' ),
);
}

}

return LLMS_Notification_Controller_Certificate_Earned::instance();
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ private function get_mini_html( $title ) {
* @return string
*/
protected function set_body() {
if ( 'email' === $this->notification->get( 'type' ) ) {
// Translators: %1$s - student name, %2$s - Certificate title.
return sprintf( __( 'Congratulations! %1$s earned a certificate: %2$s.', 'lifterlms' ) . "\n\n{{MINI_CERTIFICATE}}\n\n" . $this->set_footer(), '{{STUDENT_NAME}}', '{{CERTIFICATE_TITLE}}' );
}
return '{{MINI_CERTIFICATE}}';
}

Expand Down Expand Up @@ -213,7 +217,7 @@ private function set_merge_data_student_name( $cert ) {
* @return string
*/
protected function set_subject() {
return '';
return 'Certificate Earned: {{CERTIFICATE_TITLE}}';
}

/**
Expand All @@ -226,21 +230,4 @@ protected function set_subject() {
protected function set_title() {
return __( 'You\'ve earned a certificate!', 'lifterlms' );
}

/**
* Defines field support for the view.
*
* @since 3.8.0
*
* @return array
*/
protected function set_supported_fields() {
return array(
'basic' => array(
'body' => true,
'title' => true,
'icon' => true,
),
);
}
}
Loading