fix(notifications): add certificate earned email notification and engagement trigger#3186
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
…agement trigger - Add email support to the certificate earned notification controller and view. - Add new 'certificate_earned' engagement trigger so follow-up actions can fire when a student earns a certificate. - Update engagement trigger registry and hook mapping for llms_user_earned_certificate. - Add unit tests for email notification support. Fixes gocodebox#3143
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds email support to the existing "Certificate Earned" notification and introduces a new "Student earns a certificate" engagement trigger. Previously, the certificate earned notification only supported a popup, and there was no way to fire follow-up engagements when a certificate was awarded.
Fixes #3143
Changes
includes/notifications/controllers/class.llms.notification.controller.certificate.earned.phpBefore:
After:
Why: The controller already hooked into
llms_user_earned_certificate; adding the email type lets the existing email processor send the notification without any processor changes.includes/notifications/views/class.llms.notification.view.certificate.earned.phpBefore:
After:
Why: The view now provides a real email subject and body, while keeping the popup mini-cert preview unchanged. The merge codes for certificate title and URL were already available.
includes/llms.functions.core.phpBefore:
After:
Why: Registers the new engagement trigger in the admin dropdown so site owners can build engagements that fire after a certificate is earned.
includes/class.llms.engagements.phpBefore:
After:
Plus a new case in
parse_hook_find_trigger_type():Why: The engagement engine needs to listen to the existing
llms_user_earned_certificateaction and map it to the newcertificate_earnedtrigger type so configured engagements can run.tests/phpunit/unit-tests/notifications/class-llms-test-notification-certificate-earned.phpAdded three new tests:
test_email_supported()— confirms the controller supports bothbasicandemailtypes.test_email_subscriber_options()— confirms the email type hasstudentandcustomsubscribers.test_email_view()— confirms the email view returns subject, body, and title content with the expected merge codes.Why: Covers the new email behavior and ensures the notification UI fields are wired correctly.
Testing
Test 1: Email notification for certificate earned
Result: Works as expected
Test 2: New engagement trigger
Result: Works as expected