Skip to content

New negative and trigger engagements - #3358

Open
brianhogg wants to merge 11 commits into
devfrom
feature/negative-engagements
Open

brianhogg wants to merge 11 commits into
devfrom
feature/negative-engagements

Conversation

@brianhogg

@brianhogg brianhogg commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #3064 and #3051

How has this been tested?

Screenshots

Types of changes

Checklist:

  • This PR requires and contains at least one changelog file.
  • My code has been tested.
  • My code passes all existing automated tests.
  • My code follows the LifterLMS Coding & Documentation Standards.

Note

High Risk
Large changes to engagement firing, email dupcheck bypass, enrollment validation, and daily batched DB scans that can affect student communications and site load on large catalogs.

Overview
Expands LifterLMS engagements with negative / at-risk triggers (low course grade, repeated quiz failures, cancelled or expired enrollments, failed/refunded/cancelled orders) plus configurable thresholds (course progress %, failure count, inactivity days).

Event-driven path: New hooks map order status changes and course/membership unenrollment into trigger types; LLMS_Engagements_Thresholds listens on lesson/course/quiz hooks for progress, grade-below, and multi-fail logic with per-course/quiz fire-once markers. Engagements that fire after access is lost skip the usual enrollment check via remove_enrollment_check_errors.

Daily scan path: LLMS_Engagements_Scanner runs a recurring Action Scheduler job that batches candidates for login inactivity, stalled course progress, never-started enrollments, completion deadlines, and abandoned quiz attempts. Re-arm markers prevent duplicate fires until activity changes; scan-based emails can bypass the sent-email dupcheck when re-armed.

Admin & email: The engagement meta box adds percentage, day-count, and failure-count fields (with filters for add-ons), wires new triggers to course/membership/quiz pickers, and exposes {related_post_title} in engagement email merge codes.

Reviewed by Cursor Bugbot for commit 00b8536. Bugbot is set up for automated code reviews on this repo. Configure here.

@brianhogg brianhogg moved this to Awaiting Review in Development Sep 15, 2026
@brianhogg brianhogg moved this from Awaiting Review to Review in Progress in Development Sep 15, 2026
Comment thread includes/class-llms-engagement-handler.php
@brianhogg

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 00b8536. Configure here.

'anchor' => $last,
);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inactivity fires for completed students

High Severity

query_course_inactivity treats any enrolled student with a completion row as stalled once last activity is older than the period. Students who already finished the course stay enrolled, so they match after N days and receive inactivity engagements for a course they completed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 00b8536. Configure here.

array_merge( $user_ids, $tree )
),
OBJECT_K
); // db call ok; no-cache ok.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sends re-arm inactivity triggers

High Severity

get_last_activity treats every user-postmeta row on the course tree as student activity. Sending the engagement writes _email_sent (or award meta) on the course, which becomes a newer last-activity date and makes maybe_fire treat the send itself as a re-arm. The same inactivity engagement then fires again every period with no real student activity.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 00b8536. Configure here.

@brianhogg
brianhogg marked this pull request as ready for review September 18, 2026 14:13
@brianhogg brianhogg self-assigned this Sep 18, 2026
…leted course, warning on saving when it will trigger >=200 emails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review in Progress

Development

Successfully merging this pull request may close these issues.

1 participant