MyBB Community Forums

Full Version: Autofilling Subject and Message fields
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like MyBB to automatically fill-in the subject and message given a URL like

http://foobar.com/forum/newthread.php?fid=116&subject=A+new+topic&message=blah+blah

I think this is easy to do with a few lines of code in newthread.php, but I'm not familiar with PHP array syntax and am having a hard time trying to figure it out. Something along the lines of

if ($_GET['subject']) {
MyBB variable = urldecode($_GET['subject']);
MyBB variable = urldecode($_GET['message']);
}

Would someone be so kind as to help me with the correct variables and syntax?

I think I figured it out. In newthread.php at approximately Line 621

// Otherwise, this is our initial visit to this page.
	else
	{
		if($mybb->user['signature'] != '')
		{
			$postoptionschecked['signature'] = " checked=\"checked\"";
		}
		if($mybb->user['subscriptionmethod'] ==  1)
		{
			$postoptions_subscriptionmethod_none = "checked=\"checked\"";
		}
		else if($mybb->user['subscriptionmethod'] == 2)
		{
			$postoptions_subscriptionmethod_instant = "checked=\"checked\"";
		}
		else
		{
			$postoptions_subscriptionmethod_dont = "checked=\"checked\"";
		}
		$numpolloptions = "2";
// START OF NEW CODE	
		$subject = urldecode($_GET['subject']);
		$message = urldecode($_GET['message']);
// END OF NEW CODE	
	}
This is exactly what I am trying to figure out.

It already works fine for PM's without any code modification.

Did this work for you?

Works for me, although I changed the code slightly to

// START OF NEW CODE
$subject = $_GET['subject'];
$message = $_GET['message'];
// END OF NEW CODE