Home / Archive / MemberPress: Allow Users to Pause/Resume Subscriptions Only for Specific Memberships
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Allow Users to Pause/Resume Subscriptions Only for Specific Memberships

For this code snippet to work, the Allow members to pause/resume their subscription option needs to be enabled in the MemberPress settings.

The example code must be adjusted to allow pausing and resuming on specific memberships.

Replace dummy IDs (123 and 456) with the IDs of the memberships for which you wish to allow pausing. Update IDs on this line:

$products_to_allow = array( '123', '456' );

Code Preview
php
<?php
function maybe_hide_pause_resume_links( $link, $sub ) {
  // Replace 123, 456 with the membership IDs which members can pause/resume subscriptions for.
  $products_to_allow = array( '123', '456' );
  $product = $sub->product();
  if( in_array( $product->ID, $products_to_allow ) ) {
    return $link;
  } else {
    $link = '';
    return $link;
  }
}
add_filter( 'mepr_custom_pause_link', 'maybe_hide_pause_resume_links', 10, 2 );
add_filter( 'mepr_custom_resume_link', 'maybe_hide_pause_resume_links', 10, 2 );

Comments

Add a Comment