Results 1 to 6 of 6

Thread: Expired Ads Email Bug - explained (plus a fix)

  1. #1
    Thread Starter
    limecanvas's Avatar
    Join Date
    Mar 2013
    Location
    Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Expired Ads Email Bug - explained (plus a fix)

    It would seem that this bug has been present since 2011.

    ClassiPress does not send out an email for expired ads when the cron job purges expired ads.

    The process:
    1. File: classipress\includes\cron.php - function cp_check_expired_cron()
    This is a cron job which runs periodically.
    This checks the expiry of the Ad and if over the expiry date it changes the Ad post status from "publish" to "draft".
    This function does not send the email out. This is done in step 2

    2. File: classipress\includes\emails.php - function cp_notify_ad_owner_email()
    This is the function that is meant to email the Ad owner on expiry.
    It hooks into the "transition_post_status" filter which detects the change in a posts status using this conditional:
    PHP Code:
    elseif ( $old_status == 'publish' && $new_status == 'draft' && $current_user->ID != $ad_author_id && $send_expired_email ) { email code blah blah 
    This works well if you are logged into WordPress and manually change the post status of an expired Ad from "publish" to "draft". The email will be sent.

    HOWEVER - the bug is this.

    When the post status is changed from the cron job, it is the system which is changing the post status - not a logged in user.

    Hence when the filter is triggered from the cron job, there is no $current_user object. This is causing an error and failing the logic of the elseif clause. Hence expired emails during cron purge will never work using this logic.

    A temp fix
    If you really need this functionality then you can remove the following from the elseif statement:
    PHP Code:
    && $current_user->ID != $ad_author_id 
    so the line reads:
    PHP Code:
    elseif ( $old_status == 'publish' && $new_status == 'draft' && $send_expired_email ) { 
    Of course this is only a patch as the fix will get overwritten when ClassiPress is next updated and if AppThemes don't include a fix by then.

    This should help those in these threads:
    http://forums.appthemes.com/report-c...problem-28959/
    http://forums.appthemes.com/report-c...-14035/page-2/
    http://forums.appthemes.com/report-c...sending-29043/
    http://forums.appthemes.com/report-c...ication-28827/

  2. #2
    seoagent's Avatar
    Join Date
    Jul 2012
    Location
    Edmonton, AB, Canada
    Posts
    660
    Thanks
    136
    Thanked 86 Times in 74 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    When in doubt: Read, Ask, Do. G+

  3. #3
    Thread Starter
    limecanvas's Avatar
    Join Date
    Mar 2013
    Location
    Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    Thread Starter
    limecanvas's Avatar
    Join Date
    Mar 2013
    Location
    Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  5. #5
    Newbie englishsensei's Avatar
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #6
    dimitris's Avatar
    Join Date
    Oct 2011
    Location
    Earth
    Posts
    20,617
    Thanks
    222
    Thanked 1,873 Times in 1,770 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. email for expired ads
    By shoo in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: December 2nd, 2012, 08:15 AM
  2. Email notification on ads expired
    By alanlee9898 in forum Report ClassiPress Bugs
    Replies: 3
    Last Post: December 24th, 2011, 10:31 AM
  3. Ad Expired Email
    By kplunk in forum ClassiPress General Discussion
    Replies: 2
    Last Post: November 19th, 2010, 05:45 PM
  4. New Forum Features Explained
    By pepsi in forum WordPress General Discussion
    Replies: 1
    Last Post: August 10th, 2010, 01:10 AM