Title: [Plugin: Auto Prune Posts] Doesn&#039;t work on WordPress multisite
Last modified: August 19, 2016

---

# [Plugin: Auto Prune Posts] Doesn't work on WordPress multisite

 *  [handig](https://wordpress.org/support/users/handig/)
 * (@handig)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/)
 * Hi,
    Tried using it. But it doesn’t seem to prune the posts.
 * I set it to delete after 24 hours, but it doesn’t seem to delete anything.
 * Is there a way to check it?
 * [http://wordpress.org/extend/plugins/auto-prune-posts/](http://wordpress.org/extend/plugins/auto-prune-posts/)

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/page/2/?output_format=md)

 *  [shofer](https://wordpress.org/support/users/shofer/)
 * (@shofer)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856404)
 * hey,
 * there seems to be a bug in the plugin.
    it uses a function hat only loads the
   last 5 posts of a category instead of load all posts.
 * additionally there is a barrier so that the prune process is only triggert once
   a hour.
 * **Workarounds:**
 * For the major bug: (Line near 135 of file auto-prune-post.php)
    Replace `$myposts
   = get_posts("category=" . $cat_i);` with
 *     ```
       $args = array( 'numberposts' => -1, 'category' => $cat_id );
                   $myposts = get_posts($args);
       ```
   
 * For testing do the prune on every page hit:
    Line 127 of file auto-prune-post.
   php: add a new line to set $lastrun false every time (remove this line after 
   testing)
 *     ```
       $lastrun = get_transient('auto-prune-posts-lastrun');
       $lastrun = false;
       ```
   
 *  Thread Starter [handig](https://wordpress.org/support/users/handig/)
 * (@handig)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856413)
 * Hey Shofer,
    Thank you very much. It solved my problem. Do I understand it correctly
   that the prune process is still only triggert once a hour?
 *  [shofer](https://wordpress.org/support/users/shofer/)
 * (@shofer)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856414)
 * as long as you don’t have the
    `$lastrun = false` line inserted the process is
   only triggert once a hour. This line makes only sense in case of testing. So 
   you don’t need to wait a hour to do your next test.
 *  Thread Starter [handig](https://wordpress.org/support/users/handig/)
 * (@handig)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856415)
 * Oh, so if the line $lastrun = false is included it runs every time someone goes
   to the website (wordpress frontend) and otherwise a visit will only trigger the
   auto prune process if this has not happened in the last hour.
 * Thank you.
 *  Plugin Author [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * (@ramon-fincken)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856445)
 * Thanks Shofer for reacting to handig !
 * I just saw this topic.
 * As for the “bug” to only take 5 posts and once an hour, this is intentional to
   reduce potential serverloads.
 * I am working on a new version on which the timeout is 30 minutes and it will 
   clear all posts:
 *     ```
       /**
       	 * Uses transient instead of cronjob, will run on wp call in frontend.
       	 */
       	function prune() {
       		$lastrun = get_transient('auto-prune-posts-lastrun');
   
       		if (false === $lastrun) {
       			$force_delete = ($this->conf['settings']['force_delete'] == 0) ? false : true;
   
       			// Walk
       			foreach($this->conf['config'] as $cat_id => $type)
       			{
       				foreach($type as $the_type => $values)
       				{
       					$period_php = $values['period_php']; // Will be in format so strtotime can handle this [int][space][string] example: "4 day" or "5 month"
   
       					// Get all posts for this category
       					$myposts = get_posts('category=' . $cat_id.'&post_type='.$the_type.'&numberposts=-1');
       					foreach ($myposts AS $post) {
       						$post_date_plus_visibleperiod = strtotime($post->post_date . " +" . $period_php);
       						$now = strtotime("now");
       						if ($post_date_plus_visibleperiod < $now) {
       							// GOGOGO !
       							//$this->delete_post_and_attachments($post->ID,$force_delete);
   
       							// Mail admin?
       							if(!empty($this->conf['settings']['admin_email']))
       							{
       								$body = "DEMO, no post is delete DEMO Deleting post ID : ".$post->ID. "\n";
       								$body .= "Post title : ".$post->post_title. "\n";
       								$body .= "Settings (Delete or Trash) : ".( ($force_delete) ? 'Delete' : 'Trash' ). "\n";
       								wp_mail($this->conf['settings']['admin_email'],'Plugin auto prune posts notification',$body);
       							}
       						}
       					}
       				}
       			}
       			//set_transient('auto-prune-posts-lastrun', 'lastrun: '.time(), 60*30); // 60*30 = 30 minutes
       		}
       	}
       ```
   
 *  [ryanmc](https://wordpress.org/support/users/ryanmc/)
 * (@ryanmc)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856456)
 * Any word on when the new version will be released?
 *  Plugin Author [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * (@ramon-fincken)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856457)
 * [@ryanmc](https://wordpress.org/support/users/ryanmc/) : the expectation (planning)
   is somewhere next week, but certainly not on Monday
 *  [deenorris](https://wordpress.org/support/users/deenorris/)
 * (@deenorris)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856480)
 * Next week was two weeks ago. Should I start editing existing code or wait a few
   more days?
 *  Plugin Author [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * (@ramon-fincken)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856481)
 * It is in trunk -> [http://wordpress.org/extend/plugins/auto-prune-posts/download/](http://wordpress.org/extend/plugins/auto-prune-posts/download/),
   please have some patience.
 * I’m away this weekend.
 *  Plugin Author [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * (@ramon-fincken)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856485)
 * I have just committed version 1.1:
 *     ```
       = 1.1 =
       Second release<br/>
       Added: Custom post type support<br>
       Added: Trash OR force delete option<br>
       Added: Mail admin if post is deleted<br>
       Changed: Init method is now every 30 seconds, all posts are checked.<br>
       Added: If you add &prune=true in your admin plugin page the plugin will run manually (force run)<br>
       ```
   
 *  [filament72](https://wordpress.org/support/users/filament72/)
 * (@filament72)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856487)
 * The upgrade seems to have messed up the WP UI using multisite, I have no other
   options other than dashboard which has nothing on it but news & blog. No way 
   to get to or edit anything else and now I have a “Auto prune posts plugin updated
   to new version” line at the top of my site. Something is not right with the upgrade.
 *  Plugin Author [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * (@ramon-fincken)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856488)
 * The update notice will only show once.
 *  [filament72](https://wordpress.org/support/users/filament72/)
 * (@filament72)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856489)
 * I had to completely uninstall the plugin after the upgrade. It rendered the wordpress
   UI useless. The left menu only had options for Dashboard(which only contained
   wp news and wp blog) and Profile, thats it! Could no longer get to anything else
   within the WP UI. After uninstall all returned to normal.
 *  Plugin Author [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * (@ramon-fincken)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856490)
 * Is there any way you can retrieve your PHP error logs (of the day you installed
   and noticed the error) and sent them to me?
 *  [filament72](https://wordpress.org/support/users/filament72/)
 * (@filament72)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/#post-1856498)
 * Sorry it took so long. I really don’t have a way to access but I did for the 
   sake of trying, install the plugin fresh to the network and same result. The 
   upgraded version does not work well with multisite, not as in working incorrectly,
   but bombs out the WPUI. Not sure if that is a known issue with multisite but 
   figured I would put it out there. The old version works fine.

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/page/2/?output_format=md)

The topic ‘[Plugin: Auto Prune Posts] Doesn't work on WordPress multisite’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/auto-prune-posts.svg)
 * [Auto Prune Posts](https://wordpress.org/plugins/auto-prune-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/auto-prune-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/auto-prune-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/auto-prune-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/auto-prune-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/auto-prune-posts/reviews/)

 * 22 replies
 * 6 participants
 * Last reply from: [ramon fincken](https://wordpress.org/support/users/ramon-fincken/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/plugin-auto-prune-posts-doesnt-work-on-wordpress-multisite/page/2/#post-1856523)
 * Status: not resolved