fix(notifications): add unenrollment notification trigger - #3185
fix(notifications): add unenrollment notification trigger#3185faisalahammad wants to merge 3 commits into
Conversation
Adds a new 'unenrollment' notification that fires when a student is removed
from a course or membership. Supports popup (basic) and email delivery, with
all subscribers disabled by default per the feature request.
- New controller listens to llms_user_removed_from_course and
llms_user_removed_from_membership (the post 6.0.0 hooks).
- New view defines {{TITLE}}, {{TYPE}}, and {{STUDENT_NAME}} merge codes
with a negative icon variant.
- Register 'unenrollment' trigger in LLMS_Notifications::load().
- All subscribers default to 'no' so existing sites are not opted in.
Fixes gocodebox#3141
…pient
- set_body() now returns 'You have been unenrolled from {{TITLE}}.' for
email and '{{STUDENT_NAME}} has been unenrolled from {{TITLE}}.' for
popup, matching the pattern in
class.llms.notification.view.course.complete.php:53.
- set_subject() now returns 'You have been unenrolled from {{TITLE}}'
for self and '{{STUDENT_NAME}} unenrolled from {{TITLE}}' for others,
using is_for_self() like the existing merge-data handler.
Addresses PR gocodebox#3185 feedback.
Refs gocodebox#3141
|
@brianhogg re-review requested. Replied to all 6 review threads. Followed your direction on the @Version tags. Pushed:
Sorry for the back-and-forth on the docblock tags. |
… files Removes @Version [version] from all 4 method docblocks in the controller and all 7 method docblocks in the view, leaving only the file-level header @Version. Per maintainer direction. Addresses PR gocodebox#3185 feedback. Refs gocodebox#3141
No worries re: the docblock tags! It is a change, and I agree it might be good to just blanket update everything one way or the other at some point. But with the per-file scans on wp.org, that won't be anytime soon :) |
|
Thanks, @brianhogg! I appreciate your understanding. Yes, it would be nice to have a consistent approach to the docblock tags someday. For now, this should keep things cleaner and easier to manage. Looking forward to your further feedback! |
Summary
Adds a new
unenrollmentnotification trigger that fires when a student is removed from a course or membership. Supports both popup (basic) and email delivery, with all subscribers disabled by default so existing sites are not opted in.Fixes #3141
Description
Adds a new
unenrollmentnotification trigger that fires when a student is removed from a course or membership. Supports both popup (basic) and email delivery, with all subscribers disabled by default so existing sites are not opted in.How has this been tested?
Test 1: registration
Result: Works as expected.
Test 2: defaults disabled
Result: Works as expected.
Test 3: course unenrollment
Result: popup appears with the course title and the negative icon; the student receives the email.
Test 4: membership unenrollment
Result: same popup and email behavior, with
{{TYPE}}resolving to "Membership".Test 5: silent on hard delete
llms_delete_student_enrollment()which fires thellms_user_enrollment_deletedhook (not the unenrollment hook).Result: no notification is sent.
Screenshots
CLI/no UI change. No visual change to existing screens; a new "Unenrollment" row appears in LifterLMS → Settings → Notifications.
Types of changes
Checklist
.changelogs/issue-3141.yml).composer run-script check-cs-errorsclean).Changes
includes/notifications/controllers/class.llms.notification.controller.unenrollment.php(new)Before: no controller existed for the unenrollment event.
After:
Why: mirrors the existing
enrollmentcontroller pattern so admins configure one notification for both post types. Usesllms_user_removed_from_membershiprather than the_levelform (the_levelhook was removed in 6.0.0). Accepts 4 args because the unenrollment action passes$user_id, $post_id, $trigger, $new_status.includes/notifications/views/class.llms.notification.view.unenrollment.php(new)Before: no view existed for the unenrollment event.
After:
Why: same merge-code and formatting conventions as the
enrollmentview. Body and subject branch on notification type andis_for_self()so the recipient is addressed directly when the notification is for them. Negative icon visually signals removal. The popup auto-dismisses and is manually dismissible like the rest of the basic notifications.includes/notifications/class.llms.notifications.phpBefore:
$triggersarray ended withsubscription_cancelledfollowed byupcoming_payment_reminder.After:
'unenrollment'inserted between them to keep alphabetical order.Why: the loader pulls the controller and view from their conventional paths once the trigger is registered, so no other registration is needed.
.changelogs/issue-3141.yml(new)Why: the project's changelog tooling only picks up files ending in
.yml; this matches the contribution workflow.