Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/9896a9c4d21c8be980464e4f11850f5c to your computer and use it in GitHub Desktop.
Save ipokkel/9896a9c4d21c8be980464e4f11850f5c to your computer and use it in GitHub Desktop.
Remove the "Cancel" link for levels with an epiration date on the PMPro Account page.
<?php
/**
* Remove the "Cancel" link for levels with an epiration date on the PMPro 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_expiring_membership( $pmpro_member_action_links, $level_id ) {
// Get user's membership levels
$user_levels = pmpro_getMembershipLevelsForUser();
// Check level
foreach ( $user_levels as $key => $level ) {
if ( $level_id === $level->id && ! empty( $level->enddate ) ) {
unset( $pmpro_member_action_links['cancel'] );
}
}
return $pmpro_member_action_links;
}
add_filter( 'pmpro_member_action_links', 'my_pmpro_remove_cancel_link_expiring_membership', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment