Skip to content

feat(elementor): add enrollment visibility controls to widgets#3191

Open
faisalahammad wants to merge 1 commit into
gocodebox:devfrom
faisalahammad:fix/3099-elementor-enrollment-visibility
Open

feat(elementor): add enrollment visibility controls to widgets#3191
faisalahammad wants to merge 1 commit into
gocodebox:devfrom
faisalahammad:fix/3099-elementor-enrollment-visibility

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an Enrollment Visibility section to every LifterLMS Elementor widget. Course authors can now show or hide a widget based on the current visitor's enrollment status, login state, or enrollment in specific courses or memberships, mirroring the visibility option that already exists on standard Gutenberg blocks.

The decision is evaluated server-side in the widget base class. Inside the Elementor editor the widget always renders so authors can keep editing it regardless of their own enrollment status.

Fixes #3099

Changes

includes/elementor/class-llms-elementor-widget-base.php

Adds add_visibility_controls() which registers a new Enrollment Visibility section under the Advanced tab with two selects (Display to and Enrolled In). The render() method now evaluates those settings before delegating to a new abstract render_widget() method. Adds private helpers is_visible() and check_enrollment() that implement the same decision tree used by the blocks library.

Before: every widget rendered unconditionally.

After: a widget renders only when the current visitor passes the configured visibility check.

Why: keeps the decision logic in one place inside the widget layer so the change does not depend on edits to the vendored libraries/lifterlms-blocks package.

All six Elementor widget classes

Each widget's render() is renamed to render_widget() and now just contains the do_shortcode() call. Each widget's _register_controls() ends with $this->add_visibility_controls() so the new section is added automatically.

Before: protected function render() { echo do_shortcode( '...' ); }

After: protected function render_widget() { echo do_shortcode( '...' ); } plus a call to add_visibility_controls() at the end of _register_controls().

Why: the base class now controls the visibility gate, subclasses only define what to render.

.changelogs/3099-elementor-enrollment-visibility.yml

New hand-written changelog entry under the added type with minor significance.

Testing

  1. Install lifterlms-fix-3099.zip on a WordPress site with Elementor active.
  2. Open a course in Elementor, add a LifterLMS widget (Pricing Table, Course Progress, etc.), open the Advanced tab.
  3. Confirm the new Enrollment Visibility section shows Display to and Enrolled In controls.
  4. For each Display to value, save the page and verify the front end:
    • everyone — visible to all visitors.
    • enrolled users + in this course — visible only when the visitor is enrolled in the current course.
    • enrolled users + in any course or membership — visible when the visitor has any enrollment.
    • non-enrolled users or visitors — hidden from enrolled users.
    • logged in users / logged out users — visible only to the matching audience.
  5. In the Elementor editor, change the widget to enrolled users and confirm it still appears in the editor preview regardless of your own enrollment status.

Result: works as expected. PHPCS clean, PHPUnit suite passes aside from two pre-existing failures on dev unrelated to this change.

Screenshots

image

Add an Enrollment Visibility section to every LifterLMS Elementor
widget. Course authors can now show or hide a widget based on the
current visitor's enrollment status, login state, or enrollment in
specific courses or memberships, mirroring the visibility option
available on standard Gutenberg blocks.

A server-side render gate in the widget base class evaluates the
visibility attributes against the current user. Inside the Elementor
editor the widget always renders so authors can keep editing it
regardless of their own enrollment status.

Fixes gocodebox#3099
@faisalahammad faisalahammad requested a review from brianhogg as a code owner June 16, 2026 16:03
@brianhogg brianhogg moved this to Awaiting Review in Development Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting Review

Development

Successfully merging this pull request may close these issues.

2 participants