Skip to content

DEMO: fire REGISTRATION_DEMOGRAPHICS_CAPTURED from authn#38649

Draft
bmtcril wants to merge 1 commit into
masterfrom
bmtcril/oex26_conference_workshop
Draft

DEMO: fire REGISTRATION_DEMOGRAPHICS_CAPTURED from authn#38649
bmtcril wants to merge 1 commit into
masterfrom
bmtcril/oex26_conference_workshop

Conversation

@bmtcril
Copy link
Copy Markdown
Contributor

@bmtcril bmtcril commented May 17, 2026

For demonstration purposes only, do not merge.

Wires the LMS registration view to emit the new
REGISTRATION_DEMOGRAPHICS_CAPTURED signal (see openedx-events) immediately after a successful registration.

The two new fields, pronouns and department, are read directly out of params (which mirrors request.POST) rather than added to the RegistrationForm itself. That choice is deliberate:

  • The fields are optional everywhere. Adding them to the Django form would require every deployment - including those not running the demographics plugin - to either special-case them or carry a forked form definition.
  • StudentRegistrationRequested (an existing openedx-filters filter) already runs against the raw request data, so plugin-side validation has the same view of these fields whether or not this patch is applied.
  • The frontend slot (org.openedx.frontend.authn.register.additional_fields.v1) submits the fields as part of the standard form POST, so no API contract changes are needed.

If neither field is present in the POST, the event still fires but with empty-string values. This keeps receivers' code paths uniform; a receiver that only cares about populated demographics can short-circuit on not (demographics.pronouns or demographics.department).

Note that the hard coding of these parameters is a known anti-pattern and is used as a discussion point in the talk.

Reference: OEX 2026 workshop "Leveraging Open edX Extension Points"

Wires the LMS registration view to emit the new
``REGISTRATION_DEMOGRAPHICS_CAPTURED`` signal (added in
openedx-events #NNNN) immediately after a successful registration.

The two new fields, ``pronouns`` and ``department``, are read directly
out of ``params`` (which mirrors ``request.POST``) rather than added to
the ``RegistrationForm`` itself. That choice is deliberate:

* The fields are *optional everywhere*. Adding them to the Django form
  would require every deployment — including those not running the
  demographics plugin — to either special-case them or carry a forked
  form definition.
* ``StudentRegistrationRequested`` (an existing ``openedx-filters``
  filter) already runs against the raw request data, so plugin-side
  validation has the same view of these fields whether or not this
  patch is applied.
* The frontend slot
  (``org.openedx.frontend.authn.register.additional_fields.v1``)
  submits the fields as part of the standard form POST, so no API
  contract changes are needed.

If neither field is present in the POST, the event still fires but with
empty-string values. This keeps receivers' code paths uniform; a
receiver that only cares about populated demographics can short-circuit
on ``not (demographics.pronouns or demographics.department)``.

The filter pipeline is unchanged: validation continues to happen via
``StudentRegistrationRequested`` *before* the user is created, so a
failed validation aborts registration without firing this event.

Reference: OEX 2026 workshop "Leveraging Open edX Extension Points",
Section 5B.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant