Viewing 14 replies - 1 through 14 (of 14 total)
  • zsolt

    (@zsolt82)

    Hello

    Yes, it works

    Thread Starter shovonbk

    (@shovonbk)

    @zsolt82 Okay for testing i have added the plugin https://prnt.sc/UZtd1jxhGUEk

    And wp config file i added this code https://prnt.sc/4aC1JON5klBr

    But ad didn’t delete in 24 hours. I want expired ad should delete permanently after expire 1 hour or 5 hours(I can decide) without trash

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    do you have in the wp-config.php file the AUTO_DELETE_EXPIRED_DELTA constant defined?

    If not then the default value of 15 will be used, which means the ads will be deleted 15 days after the expiration.

    Thread Starter shovonbk

    (@shovonbk)

    @gwin I want to delete should delete it after expire 1-5 hours not 15 days. How can i do it?

    Plugin Author Greg Winiarski

    (@gwin)

    You can try adding the below line in the wp-config.php file

    
    define( 'AUTO_DELETE_EXPIRED_DELTA', 0 );
    

    but note the event that searches and deletes the Ads are run once a day only, so the Ad will be deleted anywhere from 0 to 24 hours after the expiration.

    Thread Starter shovonbk

    (@shovonbk)

    I have tried it a fresh wordpress site and it worked but i tried a old website where a lot of expired ads available. It didn’t work. Is there any way remove those expired ad easily? https://prnt.sc/KTR30jJAJCd2

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    most likely the snippet is running out of memory when trying to delete 250k posts, you would need to change the line "posts_per_page" => -1, to for example "posts_per_page" => 50, which would delete 50 ads per day.

    To mass delete all the expired Ads you can use some third-party plugin like
    https://wordpress.org/plugins/wp-bulk-delete/
    https://wordpress.org/plugins/bulk-delete/

    Thread Starter shovonbk

    (@shovonbk)

    Is it possible run the cron job run 3 times a day? Every 8 hours? If possible then how can i do it?

    Plugin Author Greg Winiarski

    (@gwin)

    In the line

    
    wp_schedule_event( time(), 'daily', 'auto_delete_expired');
    

    you can change the “daily” to “hourly” and then the event should run every hour.

    Note that if you already have the event running daily, you need to first unscheduled it before the hourly event can be registered you can do that by adding the line below at the beginning of the auto_delete_expired_setup_schedule() function

    
    $timestamp = wp_next_scheduled( 'auto_delete_expired' );
    $original_args = array();
    wp_unschedule_event( $timestamp, 'auto_delete_expired', $original_args );

    `

    Once it will start running hourly you should remove those 3 lines.

    Thread Starter shovonbk

    (@shovonbk)

    Hello, Me here again. Is there any way delete pending payment ad automatic? By the way your expired ad automatically delete solution worked well. But our website has huge pending payment ads. How can we remove them automatic?

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,

    i think the fastest way to do that would be to use a plugin like https://wordpress.org/plugins/wp-bulk-delete/, it should allow you to delete all of them at once.

    Thread Starter shovonbk

    (@shovonbk)

    It’s not possible delete manually always. So i am finding automatic solution so it will save time.

    Plugin Author Greg Winiarski

    (@gwin)

    When i will find some free time i will create a code snippet to delete old pending payments automatically in the meantime you can use that plugin to delete them for example once a week.

    Thread Starter shovonbk

    (@shovonbk)

    Okay waiting

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Auto Delete expired Ads’ is closed to new replies.