Skip to content

Deleting a Membership Level Leaves Residual References in Database #3486

@davidmutero

Description

@davidmutero

Describe the bug
When a membership level is deleted through the Paid Memberships Pro admin interface, related entries in some database tables are not removed. While the deletion process correctly clears level entries from core tables such as pmpro_memberships_users, pmpro_memberships_categories, and pmpro_membership_levels_groups, other tables like pmpro_memberships_pages may retain references to the deleted level ID.

This can result in lingering data that affects membership logic and content protection even though the level no longer exists in the system.

To Reproduce
Steps to reproduce the behavior:

  1. Use a tool like phpMyAdmin to access your WordPress database.
  2. Navigate to the pmpro_membership_levels table and note the IDs of existing levels.
  3. Delete a level from the admin under Memberships > Membership Levels.
  4. Query the pmpro_memberships_pages table (or others, such as pmpro_discount_codes_levels) for any rows referencing the deleted membership_id.
  5. Observe that some records remain, even though the associated level has been deleted.

Screenshots
If applicable, please attach a screenshot to make your issue clearer.

Expected behavior
Deleting a membership level should cleanly remove all related records referencing that level ID across PMPro database tables, including:

  • pmpro_memberships_users
  • pmpro_memberships_categories
  • pmpro_membership_levels_groups
  • pmpro_memberships_pages
  • pmpro_discount_codes_levels
  • Any other relevant metadata or cross-reference tables

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
  • This bug happens with a default WordPress theme active, or Memberlite.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment

Details ``` WordPress Version: 6.8.2 Permalink Structure: /%category%/%postname% Site Language: en_GB Time Zone: +01:00 Active Theme: Hello Elementor (v3.4.4) Active Plugins: 40 PMPro Version: 3.5.5 PHP Version: 8.2.29 MySQL Version: 8.0.41-32 Web Server Info: Apache ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions