MyBB Community Forums

Full Version: Enter a form which then posts as a new thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone know if there is any kind of script/plugin available that will allow a user to click a 'link' which then sends them to a form and then once they fill out the form, the form then creates a new thread in a certain sub-forum/category?

For example;

If I fill out a 'Ban Request' form, the details and headings from this ban request automatically creates a new thread under the 'Ban Requests' forum.

Cheers.
So you want the actual page created too, not just the code to post the thread?
Easy page to make.
I'm capable of creating the page/form, it's just the coding of how to send that form into a new thread that is the confusing part Smile
(2015-07-15, 08:41 PM)Leefish Wrote: [ -> ]You could try using XThreads. It makes it possible to have fairly extensive forms in the FIRST POST of a thread.
however XThreads is a complex plugin !

you can also try using MyBBIntegrator (eg. see this post)
Something like this would work, obviously you will need to change the variables to the FORM data.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("insert");
$posthandler->action = "thread";

$fid = 1;
$subject = "Title";
$uid = $mybb->user['uid']; // user ID
$username = $mybb->user['username'];
$message = "Message body";
$ip = $_SERVER['REMOTE_ADDR'];

$new_thread = array (
	"fid" => $fid,
	"subject" => $subject,
	"uid" => $uid,
	"username" => $username,
	"message" => $message,
	"ipaddr" => $ip
);

$posthandler->set_data($new_thread);

$valid_thread = $posthandler->validate_thread();

if (!$valid_thread) {
	die(var_dump($posthandler->get_friendly_errors()));
}

$thread_info = $posthandler->insert_thread();