[Membership 2] Incorrect status membership

When programmatically getting the subscriptions of a user. The status of the subscription is incorrect when it should be expired.

In the wp-admin, I see the right status of the subscriptions, which is expired and also the expired date lies in the past 2019-07-07. Although, when I get the subscription via

'$member->get_subscription($membership_id)'

I do get the subscription, with the right expired date although the status is active.

  • Adam Czajczyk
    • Support Gorilla

    Hello Inesta

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

    I’ve asked our developers for consultation on this so please keep an eye on this ticket and I or my colleagues will update you here with more information as soon as our developers will look into it.

    Please note: they’re dealing with lots of complex stuff on daily basis so their response time might be slightly longer than hours here on forum.

    Best regards,

    Adam

  • Nathaniel
    • New Recruit

    Hi Inesta

    Thank you for being patient while we worked on your question.

    We have a file on our gist.github.com/wpmudev-sls that we can use to fix this condition. The exact URL is https://gist.github.com/wpmudev-sls/351aaa686d6ce8f8b3fd35f9ac8418e1. To save time, I attached the .zip file here for you.

    There’s two steps we need to do for the patch:

    As a first step, please upload the content of .zip archive ms-override-cron-check.php into your /mu-plugins/ folder found in the /wp-content/ of your WP site. If the folder is not present, please create the folder in /wp-content/

    For the next step, we need to edit the file class-ms-model-relationship.php found in the folder /membership-pro/app/model This file defines the class MS_Model_Relationship

    On line 2882, we can find this function check_membership_status() and change it from

    public function check_membership_status() {

    do_action(
    'ms_model_relationship_check_membership_status_before',
    $this
    );

    to

    public function check_membership_status() {

    // added code needed for mu-plugin gist ms-override-cron-check.php
    if ( apply_filters( 'ms_model_relationship_skip_membership_status_check', false, $this ) ) {
    return;
    }

    do_action(
    'ms_model_relationship_check_membership_status_before',
    $this
    );

    Once you have added the filter to class-ms-model-relation.php and the mu-plugin, the status should be corrected from ‘Active’ to ‘Expired’ in the next cron run (this happens every 6 hours).

    If you prefer to run the cron task earlier or force run it, go to wp-admin > Membership 2 > Settings

    scroll down and close to the footer you will see a link that will force run the cron task. The link will look something like this

    Check Membership Status changes in hh hrs nn min. No pending Email Responses found

    Click that link ‘in hh hrs nn min’ and wait a minute. Then check if the subscriptions have now been set to ‘Expired’.

    When you run the code ‘$member->get_subscription($membership_id)’, the status should now return ‘Expired’.

    Please keep us in the loop about your experience with this patch. We’d gladly welcome any feedback about it.

    Best regards,

    Nathan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.