Skip to content

Limit number of memberships shown in student dashboard - #3272

Open
faisalahammad wants to merge 1 commit into
gocodebox:devfrom
faisalahammad:fix/2442-limit-memberships-loop
Open

Limit number of memberships shown in student dashboard#3272
faisalahammad wants to merge 1 commit into
gocodebox:devfrom
faisalahammad:fix/2442-limit-memberships-loop

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Description

The My Memberships tab (/my-account/my-memberships/) lists every membership a student belongs to with no cap and no pagination. lifterlms_template_my_memberships_loop() now caps the list at 500 by default. The limit can be changed with a new filter:

add_filter( 'llms_my_memberships_loop_limit', function( $limit, $student ) {
	return 10; // or 0 for no limit
}, 10, 2 );

This mirrors the existing pattern in lifterlms_template_my_courses_loop(), which already caps its list at 500 the same way.

Fixes #2442

How has this been tested?

Added PHPUnit coverage in tests/phpunit/unit-tests/functions/class-llms-test-functions-templates-dasbhoard.php:

  • Membership count under the limit renders unchanged.
  • A 0 filter value disables the cap entirely.
  • A filter that lowers the limit actually trims the rendered list.

Ran composer tests -- --filter LLMS_Test_Functions_Templates_Dashboard (11/11 passing) and composer check-cs (clean).

Manually tested on a local install: enrolled a test student in several memberships, confirmed the dashboard tab renders all of them normally, then lowered the filter to 1 and confirmed only 1 membership rendered, then set it to 0 and confirmed all memberships rendered again.

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.

The My Memberships tab listed every membership a student belongs to
with no cap. Added a filterable limit (default 500) so large lists
stop rendering unbounded output, matching how the My Courses loop
already works.

Fixes gocodebox#2442
@faisalahammad
faisalahammad requested a review from brianhogg as a code owner July 24, 2026 06:08
@brianhogg brianhogg moved this to Awaiting Review in Development Jul 24, 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