Conversation
Remove free membership levels from the levels array used by PMPro. for exsiting post https://www.paidmembershipspro.com/hide-free-levels-from-the-membership-levels-page/
These snippets will be added to this post soon.
There was a problem hiding this comment.
Pull request overview
This pull request adds a new code snippet for hiding free membership levels from the Paid Memberships Pro levels page, and updates metadata links in two related files to point to the same blog post. The changes support a blog post facelift at paidmembershipspro.com about hiding free levels.
Changes:
- Added new snippet to filter out free levels from the levels array using
pmpro_isLevelFree() - Updated metadata links in two existing level-filtering snippets to point to the same documentation
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| frontend-pages/hide-free-levels-from-levels-page.php | New snippet that filters free levels from the levels array using pmpro_isLevelFree() function |
| frontend-pages/hide-levels-from-levels-page-by-id.php | Updated metadata to add documentation link |
| frontend-pages/filter-pmpro-levels-page-levels.php | Updated metadata to add documentation link (missing "link:" prefix) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | ||
| */ | ||
|
|
||
| function pmpro_snippet_hide_free_levels_from_levels_array( $levels ) { |
There was a problem hiding this comment.
The function name uses the prefix "pmpro_snippet_" which is inconsistent with the naming convention used in the frontend-pages directory. All other files in this directory use the prefix "my_pmpro" or "my_" for their function names (e.g., my_pmpro_levels_array, my_pmpro_member_action_links). Consider renaming to follow the established pattern, such as "my_pmpro_hide_free_levels_from_levels_array".
| // Re-index the array (optional, but keeps output tidy). | ||
| return array_values( $levels ); | ||
| } | ||
| add_filter( 'pmpro_levels_array', 'pmpro_snippet_hide_free_levels_from_levels_array' ); No newline at end of file |
There was a problem hiding this comment.
The function name in the add_filter call uses "pmpro_snippet_hide_free_levels_from_levels_array" which is inconsistent with the naming convention used in the frontend-pages directory. This should be updated to match the established "my_pmpro" prefix pattern (e.g., "my_pmpro_hide_free_levels_from_levels_array") to maintain consistency with other snippets in this directory.
| * layout: snippet | ||
| * collection: frontend-pages | ||
| * category: levels, level-page | ||
| * https://www.paidmembershipspro.com/hide-free-levels-from-the-membership-levels-page/ |
There was a problem hiding this comment.
The link metadata is missing the required "link:" prefix. The metadata should be formatted as "link: https://..." to be consistent with the established pattern used in other files in the codebase.
| * https://www.paidmembershipspro.com/hide-free-levels-from-the-membership-levels-page/ | |
| * link: https://www.paidmembershipspro.com/hide-free-levels-from-the-membership-levels-page/ |
| * | ||
| * title: Hide Free Levels in PMPro Levels Page | ||
| * layout: snippet | ||
| * collection: membership-levels |
There was a problem hiding this comment.
This file is located in the frontend-pages directory but uses "collection: membership-levels" in its metadata. All other files in the frontend-pages directory use "collection: frontend-pages" as seen in hide-levels-from-levels-page-by-id.php and filter-pmpro-levels-page-levels.php. The collection metadata should match the directory structure to maintain consistency.
| * collection: membership-levels | |
| * collection: frontend-pages |
| * title: Hide Free Levels in PMPro Levels Page | ||
| * layout: snippet | ||
| * collection: membership-levels | ||
| * category: levels |
There was a problem hiding this comment.
The category metadata only lists "levels" but similar files in the frontend-pages directory use "levels, level-page" as seen in both hide-levels-from-levels-page-by-id.php and filter-pmpro-levels-page-levels.php. Consider adding "level-page" to maintain consistency with related snippets.
| * category: levels | |
| * category: levels, level-page |
Created and updated to be used on facelift of this post
https://www.paidmembershipspro.com/hide-free-levels-from-the-membership-levels-page/