Membership: leave ping does not reliably execute

Hi guys,

This is a complex one so maybe developers are the best to answer it.

I have installed Membership and setup pings.

The pings have been setup correctly but the problem is that whenever a member on a trial subscription has their trial expire then the 'leave ping' does not execute reliably.

It seems the leave pings are only fired when I'm logged in the back end of WP clicking on areas within the membership plugin. If I'm not working on the back end membership plugin, then whosever subscription is expiring on that day expires in membership successfully but no leaving ping is executed. This means some people have leave ping executed, and others do not.

The leave ping is essential to me as I have a custom script that blocks access to a external web application once a user's trial has expired. The problem is now I have people who's trial has expired in membership but are still active on my web app. If the ping does execute the script works perfectly. However I have verified through my web logs that no ping is executed. It is also not a problem with my script.

I assume this has something to do with a cron job perhaps tied to when a user uses the membership plugin. Maybe the cron job executes only when a user is using the plugin.

Now I'm looking for how its possible for the ping to reliably execute when a user's trial expires. If its a cron job then how can I execute the Cron reliably so I don't need to be in the backend everyday for the ping to execute? I assume this is more of a bug then anything else.

  • Tyler Postle

    Hey Sow,

    Hope you're doing well today and thanks for your question!

    I looked through the files related to the ping feature and don't see any reference to it using cron. I'm going to flag one of our SLS(coding experts) on this one so we can look further into this and see what the issue is :slight_smile:

    Would you mind sending your script into us? Just to ensure our SLS staff has every piece of the puzzle here and doesn't have to ask for it later.

    If you would rather not post it in our forums then that's fine, you can send it in through our private contact form:

    Send in:

    Subject: "Attn: Tyler Postle"
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me :slight_smile:

    If you could also grant support access via our WPMU DEV Dashboard:

    via admin dashboard - WPMU DEV > Support > Support Access > Grant Access.

    That would be awesome, I don't think they will need to but just in-case they need to look at your installation.

    Lastly, it does look like you're running quite an old version of Membership and your back on 3.8.3 of WordPress. If there's no particular reason for this it would be a good idea to upgrade to the latest versions :slight_smile:

    Talk to you soon!


    • Sow

      Hey Tyler,

      Your private contact form doesn't have the ability to upload attachments so I've put a dropbox link instead.

      As mentioned the problem is not with the script because when the ping does execute then the script does its job of deactivating accounts in my external web app. The problem is there is no ping execution because when I review my web logs I can't see any calls.

      When I play around the back end, then the pings do execute and I can see the calls in my web logs too.

      Also, the remote support system didn't work. Not sure why. I've sent you access to your private email instead.

      I will update WP after I evaluate the impact to my plugins.

  • Sow

    Hey Jude,

    Thanks for the info, I've updated it now. However, considering my existing version was and the change of "Fixed leaving ping issue for expired subscriptions" was supposed to have been fixed in 3.5 but I was still having the issue.

    Yesterday I also tried using the process of a running the wp cron job through crontab in my UAT site ( before you mentioned it and it still hasn't resolved the issue. It seems when I first view the 'News' box in 'Membership' > 'Membership' then goto 'Membership' > 'All Members' and view that page and then go back to 'Membership' > 'Membership' then only new leave pings shows up. This should have already been there from running the WP cron manually.

    While I don't think the updated plugin will resolve the issue I'm still going to test it out. I've installed the new version of the plugin and will create a test user with a 1 day expiry subscription and see if the ping is fired off by tomorrow.

  • Sow


    This is tragic.

    The upgrade of the new version is WORSE then before.

    Now my joining ping isn't working! Everything was fine in the previous version.

    It shows as a 404 error but when I try to 'resend' the ping then it works fine. This is the second person who has signed up with this issue. This is URGENT now because people can't register on my site properly. PLEASE HELP!

    ps. I still don't have confirmation that the leaving ping has worked yet.

  • Jude

    Hi Sow

    I'd like to take a look at the backend of your site if thats ok with you ? Also I'll need to ability to add snippets and test them so I'd need ftp access and a couple of test members created if thats all right with you.

    Can you please send in:

    - Mark to my attention - Attn: Jude Rosario
    - Link back to this thread
    - Include admin/network admin access (WordPress admin username/password)
    - Include cPanel/WHM (I will need to look at the DB when I trigger pings so please include PHPMyAdmin or similar)
    - Include FTP

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    I am looking into this on a real time basis and hopefully we will have this fixed real quick


  • Sow


    My site is BROKEN due to whatever changes you made and people are complaining and this is getting to a critical level. It's costing me business.

    This is so bad that I'm reverting to a backup so you'll lose any changes you've made. I'm sorry but I can't put up with any more downtime. I'm really shocked that my site has been left damaged when requesting for support.

    I'll also be shutting down the access I've sent you and will need to give you login details to my UAT site instead.

  • Jude

    Hey Sow,

    I did not do anything on your site which could have caused this. The only change I made was to force any joining / leaving pings to write to a log file.

    I can't login myself anymore!!! Please review the attached screenshot. I see this when I login

    I had this same issue when trying to log in with test users I created on your site. I thought it was something you were doing that caused this. Either way their logging in was not critical to my tests. My initial analysis of what happened was something to do with wp-login.php failing.

    Here was the progress I made, I was able to confirm that both joining and leaving pings worked. But I did not reach a point where I can confirm this happened every time organically and reliably even when nobody was logged in. I was waiting for the membership to expire and examine the log file.

    Either way if going back to an older version helps then go ahead. I will not need access anymore. I am looking at a solution that is independent of your WordPress or Plugin version.

    I was thinking of creating a small custom tool for your site that forces pings to fire on join / leave as an additional layer over and above what the plugin does.

    Here is the only caveat :

    Your script must be smart enough to know if the action from the ping has already been done for the member and not repeat it.

    Let me know if this works for you and I'll design the tool, as you see its a pointless effort if it cannot be used.

    • Sow

      Hi Jude,

      Thanks for that. Sorry I was quite upset before. It turns out that my host blocked the wp-login.php file because it had too many logins from different IP addresses. Maybe my site got attempted hacked which is a first for me. Not sure exactly but its back online now.

      You should be able to login again through WP but the FTP access has been removed. Just tell me what you need and I'll send you the file for now. The restore process has overwritten any possible code changes that you've made but if you wrote to a log then I should still have that file as it wouldn't have been overwritten. I think its important we get to the bottom of this.

      Also, I'm not sure how to download older versions of membership so maybe its best we try and fix what we have right now as soon as possible. Meanwhile please let me know how to downgrade also.

      I'll setup a UAT FTP access for you tomorrow, since that also has the same problem you can play around there to your hearts content. keep in mind the LIVE system still is active with your WP user/pass play around with.

      I think the small tool is good idea if we can't solve the problem at the core. But obviously its preferable if we get to the bottom of this to understand why exactly its happening. Also, my script already is able to handle when the same ping is sent twice so it should be ok.

  • Jude

    Hi Sow,

    Phew !! Am glad its fixed now. The external tool was the last resort and since my work was causing downtime and member inconvenience I thought it was best to provide a non blocking solution.

    Meanwhile please let me know how to downgrade also.

    You can download the older version you were using from here. Downgrading is as simple as deleting the old folder and replacing with the one you downloaded.

    I'll setup a UAT FTP access for you tomorrow, since that also has the same problem you can play around there

    Yeah to fix this, I'll need to reliably reproduce the issue and wait at least one day for members to expire silently to test my code. So ftp to a UAT install is helpful.

    keep in mind the LIVE system still is active with your WP user/pass play around with.

    I would prefer to avoid using this for now till I know I have a working solution and do maybe a round of final tests here.

    I think the small tool is good idea if we can't solve the problem at the core. But obviously its preferable if we get to the bottom of this to understand why exactly its happening.

    Yes that was my initial train of thought as well but zeroing in on the root cause is taking longer than anticipated and you needed urgent help so I made this suggestion. Good to know the script handles duplicate calls so this option is always on the table.

    Im gonna try and reproduce this locally and continue testing there. Do send in FTP and WP access details to your UAT install, also please include phpMyAdmin so that I can look at the DB this time round.


  • Tyler Postle

    Hey Sow,

    Thanks a ton for all your patience on this :slight_smile:

    We're escalating this to the developer so he can take a look into this for you. This is a unique issue we haven't encountered yet and since the developer will know the code best, he should be able to get this sorted quicker for you. Apologies for the delay.

    Our developers don't normally work on weekends, but I've left a note for him on this so he'll be aware and up to date when he takes a look at the thread :slight_smile:

    Hope you're having an awesome weekend!


  • Rheinard

    Hi @Sow,

    I can confirm that the 'Leave' ping for access levels don't fire as expected when a subscription expires. However, when manually dropping a subscription it pings as expected. It also works when moving from one access level to another.

    When did you want the 'Leave' ping to trigger? When a subscription expires? If so, you can add the 'Leave' ping to the 'Subscription Plan' instead of the 'Access Level'. This one triggers as expected... when the hourly cron task executes.

    I'll update the code to make sure the 'Leave' ping for the access level also triggers when a subscription expires and push it out with the next update.



  • Rheinard

    Hi @Sow,

    Yes you can add a ping to an access level, but in this case its not what you want.

    Some additional things to consider about how Membership deals with expiration that might clear things up. Membership keeps track of some of the tasks it runs during cron so that it doesn't have to put unwanted load on your server. This means that sometimes it will mark a subscription for expiration rather than expiring it.

    If that happens then the ping will only execute the next time the member logs in, or if enough time has elapsed for cron to pick up the task again (could be up to 6 hrs from when the last cron task ran). Visiting the 'All Members' page as admin also triggers the ping if its waiting for cron or the member to log in.

    I think this could be where the confusion comes in. The ping seems unreliable and testing it has had a few people in this support ticket already scratching their head.

    Please try the following...

    Create a subscription with the following settings: "Finite", 1 day, $0. Then have a test user subscribe to the subscription. Then from the test user's registration page unsubscribe.

    Your join ping should have fired when the user subscribed, but the leave ping did not yet fire.

    Now you can either wait a day, or if you go to your database, you can change the expirydate field in the wp_m_membership_relationships table for your test user to 2 days ago.

    Try to login with your test user and the leave ping should fire. Or, if you visit 'All Members', or if the membership cron is ready for some cleanup tasks.

    I hope this helps.

    Your ticket did help find the other bug which will be fixed and pushed out soon too.


  • Sow

    Hi Rheinard,

    so I guess your saying this is 'unreliability' is done on purpose to reduce the load on the server?

    While I can understand this, I'd like to point out that there is a flaw in this concept because it assumes that users actually care to log back in. Many users register once, roam around the site, decide they aren't interested and never login again. This makes it the ping not fire for those users which makes the leaving ping quite out of sync with the joining ping.

    I'd like to point out that is a flawed concept not only just for my case but anyone who even uses membership for standard functionality.

    Let me explain -

    The main reason why pings are used are to subscribe and unsubscribe users from mailing lists like mail chip. Now let's assume someone else wants to use mail chip to subscribe their members through the membership plugin. Let's say there is a 'silver' and 'gold' memberships and there is a certain user is on 'gold'. The joining ping subscribes him to the 'gold' mailing list which are exclusive offers for gold members only. Then let's say he gets bored and never logs in again to the site. Even after his membership expires he stays on the gold subscription mailing list and has exclusive offers that he isn't supposed to get. This is a real business problem and worse then putting a little additional load on the server.

    What is worse is that if your an admin and go to 'all members' then it will only fire off pings that are ready to fire FOR THAT DAY ONLY. it will 'forget' to fire pings made a day before. This is from my experience.

    So based on the above I think it's really important we have the option to add that load to the server to ensure we have correct leave pings firing.

    Is there a way to force the pings to fire on a periodic basis that is as reliable as the join ping?

  • Jude

    Hi there Sow,

    I was watching this thread and I can see that its taking Rheinard some time to respond, I had a chat with him and he is really busy with a ton of work. I understand that this feature is critical to your business and I have a fix for you

    add_action( 'membership_mark_for_expire', 'M_ping_expiresub', 15, 2 );

    Just add this one line of code in either your functions.php or a site specific plugin if you use one. The solution is really obvious and simple after Rhienard explained how the Member class worked internally.

    What this does is as the Membership cron runs, it checks if a user is marked for expiry and fires leave pings for that user. It does not wait for the expiry to happen in your database which as he explained may add unwarranted load to the server.

    Also you have made a valid business case on why the pings should be fired without having to wait for either admin action or the user having to come back. I will be writing a patch to address this, it should be part of one of the upcoming releases.

    Please accept our apologies for the long delay in this thread.

    Hope this helps

  • Sow

    Hi Jude,

    Thanks, I almost gave up on getting a reply and made a script myself, but this is still good to have.

    I will try it on my DEV site and report back.

    Meanwhile, I accidentally upgraded my membership plugin again and have the same issue with the Ping history showing as '404 - not found' where the site is online at the same moment. Reverting back to the old version seems to not have an issue. Can you please also review why this is happening? I'd really like to upgrade to the latest version.

    I'd also like to also know when you've completed the patch that your writing to fix the ping issue once and for all.

  • Sow

    Hi Guys,

    Any update on this??? It's been awhile with no updates and it seems I'm constantly asking.

    Isn't there a workaround at least for the time being? Most work arounds provided earlier has failed.

    The support experience I've had with this has been pretty bad. I've been constantly checking up on this and its been impacting my business and costing me $$. To be honest it makes me wonder why I'm on this WPMU subscription.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.