Developer notes: hooks and filters

The filters and actions for branding, profile fields, lesson layouts, quizzes, assignments and more.

Branding

  • nonprofit_lms_branding_tokens receives the whole token map plus the saved settings.
  • nonprofit_lms_branding_updated fires after a save.
  • The REST routes live under nonprofit-lms/v1/settings/branding and need the manage_lms capability.

Profile fields and certificates

  • nonprofit_lms_profile_field_parts filters the part labels of an address or name field (relabel “State / Province” as “County”, say). Keys and order are fixed.
  • Certificate templates can use {profile:your-field} for the one line value and {profile:your-field:city} (or street, street2, state, postal, first, last) for a part.
  • The Students and export REST filters (field_your-field=…) accept every active field, whether or not it’s offered as a filter on screen.

Date fields

  • nonprofit_lms_date_field_years receives and returns an array with start and end years. The default is this year back one hundred.
  • nonprofit_lms_date_field_parts_order receives and returns the order of 'month', 'day' and 'year', for day, month, year order outside the US, for example. The stored value is always a single YYYY-MM-DD date, so reports and exports don’t change.
  • nonprofit_lms_consent_notice_rendered filters the notice after the {privacy_policy} and {terms} placeholders have become links.

Page builder layouts in lessons

Lesson content is expanded with do_shortcode() when the student player fetches it, so any shortcode works inside a lesson. Because that happens in a REST request, the player page scans the course’s lessons up front and loads each referenced layout’s assets itself.

  • nonprofit_lms_lesson_layout_shortcodes maps a layout shortcode tag to its asset callback. Beaver Builder ships as the one entry; add another builder here rather than touching the player.
  • After content lands in the page, the player dispatches nonprofit-lms:content-injected on document, with { container, lessonId }. That’s where a builder’s own re-init runs.
  • A shortcode expanded in a lesson runs without a current post, so anything that depends on get_the_ID() behaves differently there than on a page.

Interactive elements

  • The placement tag is [lms_element key="…"] (or [lms_element id="…"] for a row by its database id). It’s plain text in the stored lesson content and is resolved once, on the server, into the content_segments of the student lesson payload.
  • nonprofit_lms_element_placement receives the resolved { segments, placed_keys }.
  • nonprofit_lms_slideshow_slides receives the slides of an Interactive Slideshow (image URL, srcset, alt, dimensions).

Quizzes

  • nonprofit_lms_grade_quiz_response can override grading.
  • A question students have answered is archived rather than deleted when a save drops it (archived_at on lms_quiz_questions and lms_survey_questions). Four actions fire around that write, each with the question id and its quiz or survey id: nonprofit_lms_before_quiz_question_archived, nonprofit_lms_after_quiz_question_archived, nonprofit_lms_before_survey_question_archived and nonprofit_lms_after_survey_question_archived.
  • Each question in nonprofit-lms/v1/reports/courses/{course_id}/quiz-analysis carries a boolean no_correct_answer.
  • nonprofit_lms_quiz_attempt_expired fires once with the old attempt’s id, the user id and the quiz id when a new attempt replaces an expired one.
  • DELETE /wp-json/nonprofit-lms/v1/quizzes/{quiz_id}/attempts/{user_id} resets attempts without deleting anything, and nonprofit_lms_after_quiz_attempts_reset receives the ids it reset.

Assignments

  • nonprofit_lms_assignment_allowed_file_types (pdf, doc, docx, txt, rtf, odt, jpg, jpeg, png, gif and zip by default) and nonprofit_lms_assignment_max_file_bytes (25 MB by default) set what students can upload.
  • nonprofit_lms_submissions_dir changes where submission files are stored.
  • nonprofit_lms_allow_assignment_resubmission (default false, with the user id and assignment id) allows another submission.
  • A daily WP-Cron event, nonprofit_lms_sweep_unsubmitted_files, deletes up to 100 unsubmitted files older than a day, and nonprofit_lms_unsubmitted_file_swept fires for each.

REST routes and ids

Routes that check an instructor’s course take the course from the item named in the route’s own address, never from a course_id or topic_id in the query string or body. A request that names a different course is refused with a 403. Every id in a route must be a plain positive whole number.

Still stuck?

Search the knowledgebase for another angle, or head to support. Pro customers can open a ticket there.