Last active
June 18, 2025 12:02
-
-
Save ipokkel/68c3d6d19ebe60b963689ebe36d5a03a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove the "Cancel" membership action link from the account page. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_remove_cancel_link_per_level( $pmpro_member_action_links ) { | |
// For which levels should we remove the "Cancel" link? | |
$levels = array( 1, 2, 3 ); // Level IDs go here | |
// Get user's membership levels | |
$user_levels = pmpro_getMembershipLevelsForUser(); | |
// Check level | |
foreach ( $user_levels as $key => $level ) { | |
if ( in_array( $level->id, $levels, false ) ) { | |
unset( $pmpro_member_action_links['cancel'] ); | |
} | |
} | |
return $pmpro_member_action_links; | |
} | |
add_filter( 'pmpro_member_action_links', 'my_pmpro_remove_cancel_link_per_level', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment