Ready to get started?Download WordPress


Paid Memberships Pro
[resolved] Delete User account when cancel PMP subscription (7 posts)

  1. TC.K
    Posted 1 year ago #

    I want the users account deleted once they are cancel their subscription. However, their posts still remain in the site. How can I do that?

    I noticed their is a thread that talk about this, here. However, that is the solution for prior v1.4.

    The pmpro_delete_user seem already included in the newer version of PMP. But I still doesn't see how to use it. Do I need to changing their membership level to 0, manually? Or it already in the system that the user level will become 0 when they cancel the subscription?


  2. strangerstudios
    Plugin Author

    Posted 1 year ago #

    With the latest PMPro version, you should just be able to add this code to your functions.php (or a blank plugin) to get the functionality you want:


    (The rest of that thread talked about how to patch PMPro to work with that code, but the latest versions have the hooks in place.)

    Let me know if this works.

  3. tophersimon
    Posted 1 year ago #

    Thank you for this code. It works almost perfectly, however I get a strange email when someone cancels:

    There was an error canceling the subscription for user with ID=5. You will want to check your payment gateway to see if their subscription is still active.

    Error: not is changing?

    Last Invoice:
    'id' => '4',
    'code' => '81E76DC8B5',
    'session_id' => 'ks5u5tefpa6jfsr2mfkvikp3d0',
    'user_id' => '5',
    'membership_id' => '2',
    'paypal_token' => '',
    'billing_name' => 'Test Testing',
    'billing_street' => '123 Easy St',
    'billing_city' => 'Palo Alto',
    'billing_state' => 'California',
    'billing_zip' => '94303',
    'billing_country' => 'US',
    'billing_phone' => '4083728674',
    'subtotal' => '125.00',
    'tax' => '0',
    'couponamount' => '',
    'certificate_id' => '0',
    'certificateamount' => '',
    'total' => '125',
    'payment_type' => '',
    'cardtype' => 'Visa',
    'accountnumber' => 'XXXXXXXXXXXX0000',
    'expirationmonth' => '01',
    'expirationyear' => '2013',
    'status' => 'cancelled',
    'gateway' => '',
    'gateway_environment' => 'sandbox',
    'payment_transaction_id' => 'TEST81E76DC8B5',
    'subscription_transaction_id' => 'TEST81E76DC8B5',
    'timestamp' => '2013-02-05 10:11:17',
    'affiliate_id' => '',
    'affiliate_subid' => '',

    However, it still works and deletes the WP user as expected.

    Any thoughts?

  4. strangerstudios
    Plugin Author

    Posted 1 year ago #

    @tophersimon, what's happening is PMPro is trying to cancel their subscription twice. Once when they cancel and then again when the account is deleted (because PMPro hooks into user deletion to cancel the users account - basically the other order of doing things).

    The email is harmless. Their subscription will have been cancelled.

    I will try to update the code so it doesn't do the double cancel.

  5. strangerstudios
    Plugin Author

    Posted 1 year ago #

    @tophersimon, I've updated the gist to avoid the double cancel issue. Let me know if this works for you.


  6. tophersimon
    Posted 1 year ago #

    Thanks! Works perfectly now. You rock!

  7. strangerstudios
    Plugin Author

    Posted 1 year ago #

    Thanks. Just resolving this thread.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic