MyBB Community Forums

Full Version: How to manually add a thread in MyBB?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been looking for a plugin that would automatically reply to each new thread made in a certain forum.
I would basically like that everytime a new user posts to the Introductions forum, he would receive a standard Welcome reply to it's thread, reply made by a certain user (I created one specifically for this sort of things). However, such a plugin doesn't exist so I tried to do it myself by doing a small modification to the newthread.php file and just inserting that data in the mybb_posts table if the fid of the new thread matches the one I want but it would be kind of tricky, because I guess I should make modifications to other tables too (the mybb_users for start, to increment the post count) and I don't know everything that I must update.
I tried to look trough the newthread.php file and the classes of mybb but I wasn't able to completely understand them.
Can anyone tell how can I manually add a new thread? Or how to make a function that does that? Maybe something like... filling an array with certain values (forum id, thread subject, author etc.) and then use a mybb class with that array as a parameter...
I really don't know what to do...
Can anyone please help me with this? I really need some advice or to be pointed in the right direction Huh
I think you can create a "Task" for this with a mysql query...
Threads tid="y" (mybb_threads) with "0" replies in a fid = "x" create a new reply pid="?" (mybb_posts) like "message"

just a suggestion, as I donĀ“t have a clue how the hell "posthash" is created, this is the only help I can provide to you atm Toungue
That's actually a pretty good idea :-?
I'm going to check the Task System right away and if I manage to do something, I'll update this post.

[edit]
Damn, it's no good.
The "create new reply" is the problem. I don't know how to completely do that. I mean... ok, I insert a new reply in the posts database, I upgrade the post count but ... I don't know... I guess there are other changes that take place when someone posts. I wouldn't want to do this by just upgrading the post count and runing some simple queries and then end up with my whole forum stats and table messed up.
My knowledge on this is not good but there must be a way to hook into the new thread script, see if the thread is being made in the introductions forum based on fid, and then add a reply to it.
Matt's right - you can hook into the newthread.php and automatically reply (using the posthandler - updates almost everything that way!) to the new thread.

To save many hours trying to explain how this works, here's a nice little plugin I pulled together. This has only been tested on a default MyBB 1.4.4, PHP 5.2.8 and mySQL 5.1.30 - so I have no idea whether this will work everywhere.

For full instructions see My Plugin List.

I've cheekily added it as an attachment here, but to understand how to use it please see the above thread...
Thanks for your help, guys!
And especially you, Tom! Your plugin was just what I needed!
I'm really thankful for that, I've been struggling to solve that matter for quite a while now!