Home / Archive / MemberPress: Hide the Cancel Link in the Account Page for a Period of Time
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Hide the Cancel Link in the Account Page for a Period of Time

The code will hide the subscription cancellation link on the Account page for a set period of time, thus preventing users from canceling subscriptions. In the example below, the Cancel link will be hidden until the user has been active for three months.

The code can be modified to update the period - e.g. +2 months, +200 days. The available time variations can be found here: https://www.php.net/manual/en/function.strtotime.php.

Code Preview
php
<?php
function mepr_remove_cancel_link( $link, $sub ) {
    $time = strtotime( $sub->created_at );
    if( time() < strtotime( "+3 months", $time ) ) {
      return '';
    }
  return $link;
}
add_filter( 'mepr_custom_cancel_link', 'mepr_remove_cancel_link', 10, 2 );

Comments

Add a Comment