Send user an email when they cancel

Is there any way to send a user a confirmation e-mail when they cancel their subscription (using Stripe Pro forms)?

Thank you!

See https://www.s2member.com/forums/topic/email-to-user-on-payment-cancellation/index.html

1 Like

Thank you, very helpful!

I understand that I need to make a php file and put it in the mu-plugins folder. Then I put a link like this in cancellation notifications: https://www.schooloflifedesign.com/s2_cancel_email=yes&email=%%user_email%%

Then, in my PHP file I need something like this:

<?php
add_action('init', 's2_cancel_email');
function s2_cancel_email()
    {
        if(!empty($_GET['s2_cancel_email']) && $_GET['s2_cancel_email'] === 'yes') 
      
            {
                if(!empty($_GET['email']) )
         
                    {
                     
							$to = 'email';
							$subject = 'Your Magickal Library Subscription has been cancelled';
							$body = 'You will have access until the end of your paid billing cycle.';
							
 
							wp_mail( $to, $subject, $body, );
                    }
                
            }
    }

Is this correct?

The url needs to use /? since it is passing a parameter and not referencing a sub-folder:

https://www.schooloflifedesign.com/?s2_cancel_email=yes&email=%%user_email%%

Your $to variable is being set to a string and not the passed-in parameter. Should be:

$to = $_GET['email'];

1 Like

It worked, thank you so much! Tim saves the day again!

Glad it works :slight_smile: