After Payment action hook

Looking to work with custom code, so would like to know how to get the status of a membership like Pending, Active, Completed etc once a User has made a payment, or in a trial etc for a membership

Would like to know if there is any function, or hook to check the status of a membership subscription status etc. Would like some guidance based on this.

  • Nithin

    Hello Jing,

    I'm pinging our developer regarding this, so that he could guide you better regarding this, and on what exact action, or hook would be needed to make this work.

    Please do note that developers work round the clock with many critical issues, and hence have a slow response time. Either myself, or the developer will keep you updated in this support ticket asap. Have a great day ahead. :slight_smile:

    Best Regards,

  • Jing

    ok thanks,

    let me explain whole scenario what i need
    I need to add some limitation to user after the payment was successfully done , i need to add a some extra information in my custom table ,
    so when user coming from payment getway and redirect to the thank you page then i need to add a data in my custom table so is this possible..?
    is there any action in membership 2 plugin..?


  • Panos

    Hey Jing ,

    It will require some tweaking and testing as each gateway has it's own hooks. I can provide a guide which you can try out. I try to explain in which case each is used:

    For PayPal 
    //If you are using PayPal standard (for recurring payments)
    add_action( 'ms_gateway_paypalstandard_payment_processed_pay', 'ms_paypal_gateway_subscription_paid', 20, 2 );
    //If you are using PayPal for one-time payments
    // Current hook
    add_action( 'ms_gateway_paypalsingle_payment_processed_', 'ms_paypal_gateway_subscription_paid', 20, 2 );
    // Hook in next release
    add_action( 'ms_gateway_paypalsingle_payment_processed_paid', 'ms_paypal_gateway_subscription_paid', 20, 2 );
    function ms_paypal_gateway_subscription_paid( $invoice, $subscription ) {
    	// You can use the $subscription object
    For Stripe
    // For Stripe single payments
    add_filter( 'ms_gateway_stripe_process_purchase', 'ms_stripe_gateway_subscription_paid', 20 );
    // For Stripe recurring payments
    add_filter( 'ms_gateway_stripeplan_process_purchase', 'ms_stripe_gateway_subscription_paid', 20 );
    function ms_stripe_gateway_subscription_paid( $invoice ) {
    	//You can access subscription via invoice:
    	$subscription = $invoice->get_subscription();	
    	// Do not forget to return the invoice
    	return $invoice;

    Hope this helps :slight_smile:

    Please let me know if there is something that is not clear.


  • Jing

    HI , Thanks For Reply
    i have used this code but is not working ,
    i am using PayPal standard payment getway when i use this code and just print the echo "hi"
    exit and then i register the new membership and make a payment using standard payment getway
    and when payment is done successfully i redirected on the thank you page,
    so nothing happen here using this code
    am i doing any wrong way..?