Support » Plugin: Paid Memberships Pro » Membership access not removed when WooCommerce Subscriptions expires

  • Resolved chewventure

    (@chewventure)


    Hi,

    I have WooCommerce Subscriptions and Paid Memberships Pro installed.

    I have not set any expiration dates for my Member Level within Paid Memberships Pro.

    I am letting WooCommerce handle the checkout process.

    I have a WooCommerce product that has an associated subscription that provides the user with a Membership level – e.g. Member level ‘gold’ for 3 months.

    After 3 months WooCommerce’s subscription expires and they are no longer billed, however the Membership level is not removed from the user and they are still able to access restricted content.

    What can I do to remedy this?

    Many thanks

    P.s. I have checked my cron jobs as per https://wordpress.org/support/topic/expired-users-can-see-restricted-content/ and I can see the following:

    Hook pmpro_cron_expire_memberships
    Arguments None
    Next Run (UTC+13) 2020-10-30 21:43:51 21 hours 46 minutes
    Action pmpro_cron_expire_memberships()
    Recurrence Once Daily

    P.p.s when I run https://yourwebsiteURL/wp-content/plugins/paid-memberships-pro/scheduled/expirememberships.php my screen stays blank even though I can see my test user still has a Membership that was granted by purchasing a 1 day subscription product that is already showing as expired in WooCommerce’s Subscription list.

    • This topic was modified 6 months, 2 weeks ago by chewventure.
    • This topic was modified 6 months, 2 weeks ago by chewventure.
    • This topic was modified 6 months, 2 weeks ago by chewventure.
    • This topic was modified 6 months, 2 weeks ago by chewventure.
    • This topic was modified 6 months, 2 weeks ago by chewventure.
    • This topic was modified 6 months, 2 weeks ago by chewventure.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter chewventure

    (@chewventure)

    Just for clarity the situation is:

    – WooCommerce Product has Subscription with PMP Membership associated
    – User purchases Product
    – User is correctly granted PMP Membership
    – Product Subscription expires
    – WooCommerce correctly shows Subscription as expired
    – PMP Membership does not remove Membership from User.

    I’ve waited nearly 48 hours for my test User who purchased a 24 hour Subscription and they still have the PMP Membership assigned to them.

    • This reply was modified 6 months, 2 weeks ago by chewventure.
    Plugin Author Andrew Lima

    (@andrewza)

    Hi @chewventure,

    Thank you for using Paid Memberships Pro. I’m really sorry to hear about the issue you are facing here.

    We are going to run some further tests regarding WooCommerce Subscriptions and Paid Memberships Pro. For the time being, please manually cancel the user’s membership level.

    Also, please post any questions to relating to Paid Memberships Pro – WooCommerce Integration here – https://wordpress.org/support/plugin/pmpro-woocommerce/

    I’ll revert back as soon as I possibly can.

    Thread Starter chewventure

    (@chewventure)

    Hi @andrewza, thanks for the response – would you like me to repost the question in the WooCommerce Intergration forum?

    Looking forward to hearing about the results of your testing!

    Cheers

    • This reply was modified 6 months, 2 weeks ago by chewventure.
    Thread Starter chewventure

    (@chewventure)

    Hi @andrewza – did you have any success with the testing?

    Cheers

    Plugin Author Andrew Lima

    (@andrewza)

    We are still working through this issue and will revert as soon as we possibly can, this may take a couple of days. Thank you for your patience.

    • This reply was modified 6 months, 2 weeks ago by Andrew Lima.
    Thread Starter chewventure

    (@chewventure)

    Thanks for the response @andrewza

    Thread Starter chewventure

    (@chewventure)

    Ok, so I wrote my own very clunky cron job to clear the Membership level if the user has no active Subscriptions using:

    include_once("wp-config.php");
    include_once("wp-includes/wp-db.php");
    
    global $wpdb;
    
    $sql = "UPDATE wp_pmpro_memberships_users
    SET wp_pmpro_memberships_users.status = 'admin_cancelled'
    WHERE wp_pmpro_memberships_users.user_id IN 
        (
        /*Select all users that have an active Membership but no active Subscription*/
        SELECT pmpro.user_id FROM (SELECT * FROM wp_pmpro_memberships_users) as pmpro
        JOIN wp_pmpro_membership_levels as pmprol ON pmprol.id=pmpro.membership_id
        JOIN wp_users ON pmpro.user_id = wp_users.ID
        WHERE pmpro.status = 'active'
        AND pmpro.user_id NOT IN 
            (
            /*Select all users that have an active Subscription*/
            SELECT meta.meta_value 
            FROM wp_posts as p
            JOIN wp_postmeta as meta
            ON meta.post_id = p.id
            JOIN wp_users as u
            ON meta.meta_value = u.id
            WHERE post_type LIKE 'shop_subscription'
            AND post_status LIKE 'wc-active'
            AND meta.meta_key = '_customer_user'
            )
        )";
    	
    $results = $wpdb->get_results($sql);
    • This reply was modified 6 months, 1 week ago by chewventure.
    Thread Starter chewventure

    (@chewventure)

    @andrewza did you have any luck with the investigation with this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.