is there a hook when cancel a membership

Hello

is there a hook that I can use when a subscription to a membership is canceled?

BR
/Cristina

  • Adam Czajczyk
    • Support Gorilla

    Hello Cristina,

    I hope you're well today and thank you for your question!

    I think you should be able to hook to

    ms_model_membership_cancel_membership

    action. In case you'd need further assistance with this, please give me as much details about what you'd wish to achieve and I'll be happy to help.

    Best regards,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hello Cristina!

    It's using membership id: "$membership_id", I'm sorry I should have share this previously :slight_smile:

    Please note though, that with Membership 2 Pro release an API came up that may be a better way of interacting with the plugin. You'll find API documentation on your dashboard's "Membership 2 -> Help -> API Docs" page.

    Best regards,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hello Cristina,

    I hope you're having a nice day!

    I think we should better make sure that we're an the same side here :slight_smile: Could you please share with me a bit more detailed explanation on what would you like to achieve? An example case scenario would be of great help here!

    Best regards,
    Adam

  • Cristina Krügnell
    • Site Builder, Child of Zeus

    I want to be able to hook into the flow when I cancel a membership from Admin so I can do some other things at the same.

    When I create memberships I use the hook
    ms_model_relationship_create_ms_relationship

    I want to be able to use the corresponding hook when I cancel a membership.

    BR
    /Cristina

  • Adam Czajczyk
    • Support Gorilla

    Hello Cristina,

    Thank you for your replay. Assuming you'd like to run some code upon membership cancellation, these snippets should be of help. I think either the first or the second one should do the job here:

    function wpmu_on_cancel_membership($membership_id,$object) {
    // do your code here
    }
    add_action('ms_model_membership_cancel_membership', 'wpmu_on_cancel_membership',99,2);
    add_action( 'ms_model_event', 'my_custom_func', 99, 2 );
    function my_custom_func( $event, $data ) {
        if( $event->type == MS_Model_Event::TYPE_MS_CANCELED ) {
    // do your code here
    }
    }

    The first one uses action that I referred to previously and the second one uses API.

    Let me know please if it helped!

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.