![]() |
automating thread moves between forums
I need to create some sort of scheduled task or cron job to move all of the threads from one forum to another forum on a daily basis... any suggestions on the best way to approach it? custom sql queries? custom php code that uses vB functions?
vB 3.0.7 Thanks Jason |
Based on what rules these moves should be done?
|
I have forum A that is publically viewable. I have forum B that is only viewable by admins. at midnight every night, I need to move ALL threads in forum A to forum B. So, the only rule to identify threads to be moved is that forum=A
|
A relative easy cronjob should be able to do that. So you will have to write a short php-script that can perform the task.
|
PHP Code:
|
Kirby, that was perfect -- Thanks! It worked great in my test site and will hopefully run on my prod site at midnight tonight.
Fortunately, Forum A has "Count Posts Made in this Forum Towards User Post Counts" set to No, so that works out well. This is basically our venting forum.. it allows users to say things they might not otherwise say, knowing that everything will get "purged" daily. Thanks again. |
I think I'm looking for the same thing; the only difference is adding 1 parameter to see if the thread should be moved.
I'd like to move all threads in one forum with at least 1 reply (2 posts within thread) to be auto-moved to another forum. Do I just need to add an "AND replycount >=1" clause? UPDATE: Working like a charm. If anyone needs the code, the bottom snippet moves all threads with replies from forum id #17 over to forum id #2. I have it running as a cron job once an hour. Code:
<?php |
I love you. I'm clearly going to be using this. w00t!
|
I used this code and a cron job to auto move threads from my news forum in 3.09. Since I upgraded to 3.5.4, it no longer works. Anyone know why?
|
Minor change in the function names for accessing the db in 3.5.X:
Code:
<?php |
Thank you very much! It works again.:)
|
Does this works in vb 3.6.1?
|
Works fine in 3.6.1. Only glitch I've found (which isn't new to 3.6.1, it is been this way through quite a few versions) is when dealing with the new post flag.
If I read the thread in the news forum, and post a reply, it is marked as read. Then it gets moved over to my discussion forum. When I click on the forum, the thread appears to be read already, but at the forumhome page, there appears to be new posts within the discussion forum. Sometimes this goes away by clicking on that thread again, but sometimes it appears not to clear the new post flag until I hit "mark all posts read" at the bottom of the main page. I wonder if there is another maintenance function that would be useful in addition to "build forumcounters". EDIT: At first glance, it looks like "build_thread_counters($threadid)" would be the function to clean up this last (minor) issue, but unfortunately it requiers the $threadid parameter, which we don't touch in the code above; just changing all forum id's at once for certain threads in the THREAD table; not then calling each one of those particular threads to build counters after making the switch. |
i think that's because your forum cleanup hasn't been run yet.
|
Quote:
|
oh, how do I copy thread to another forum instead of move thread. And also have a condition to move only threads that are 2 weeks old. Thanx a bunch
|
I know this is an old topic, but I want to know if I can use this code on vB 3.8
My next question is, where to put the code? Do I have to make a special page? |
That is a cron job/scheduled task. So, you would make a page with that php in it and put it somewhere (/includes/cron ?) and then run it as a scheduled task. I have no idea if it works for 3.8. I suppose you could try it on a test forum.
|
Thanks Lynne, I will try it on a local test forum. I thought it would be something like this, but now I know it for sure. ;)
|
We've tried this code, but it doesn't seem to do anything. Is there anyone that knows how to rewrite it for 3.7.x?
|
Quote:
|
All times are GMT. The time now is 04:43 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|