Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Created February 3, 2015 18:13
Show Gist options
  • Save JudeRosario/260baf98ba814c2ea597 to your computer and use it in GitHub Desktop.
Save JudeRosario/260baf98ba814c2ea597 to your computer and use it in GitHub Desktop.
Membership notify me on expiry
add_action( 'membership_expire_subscription', 'notify_expiry', 10, 2 );
function notify_expiry( $sub_id, $user_id ) {
$user = get_userdata($user_id);
// You can also filter only specific subscriptions here
$sub = Membership_Plugin::factory()->get_subscription( $sub_id );
// Put your email here
$to = 'put_your_email@here.com' ;
$subject = "Membership Expiry" ;
// Format email content if needed
$message = sprintf(__( '<strong>%s</strong> has left subscription <strong>%s</strong>','membership' ), $user->display_name, $sub->sub_name() );
wp_mail( $to, $subject, $message );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment