Skip to content

Instantly share code, notes, and snippets.

@cartpauj
Created April 23, 2021 17:03
Show Gist options
  • Save cartpauj/8691e79e33f8fd7ab054348d7bb9661c to your computer and use it in GitHub Desktop.
Save cartpauj/8691e79e33f8fd7ab054348d7bb9661c to your computer and use it in GitHub Desktop.
Hide cancel link in MP until user has been active for 3 months.
<?php
add_filter('mepr_custom_cancel_link', function($link, $sub) {
$time = strtotime($sub->created_at);
if(time() < strtotime("+3 months", $time)) {
return '';
}
return $link;
}, 10, 2);
@ThemeGravity
Copy link

ThemeGravity commented May 7, 2021

Hi @photopop,

Keep in mind that this code will hide or show the Cancel button in the user Account → Subscriptions tab. It doesn't listen to click event so we can't check when the user cancels subscription.

If you want users to be able to cancel membership for 30 days after sign up you can change the code like this:

add_filter('mepr_custom_cancel_link', function($link, $sub) {
  $time = strtotime($sub->created_at);
  if(time() < strtotime("+1 month", $time)) {
    return $link;
  }
  return '';
}, 10, 2);

Hopefully, that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment