MyBB Community Forums

Full Version: Adding replies for every reps added...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to add automatic replies to the reputations added ?

If I add reputation for a thread, a reply must be made to that thread stating the number of reps added by a user....

Can any one help ?
I tried to add a reply to a thread when a user reputes it..

So I found this line in reputation.php
$db->update_query("users", array('reputation' => intval($reputation_value)), "uid='{$uid}'");

and added code after this...
But I didn get it..

$user = $db->fetch_array($db->simple_select("users", "*", "uid = '".$uid."'", array("limit" => 1)));
			require_once MYBB_ROOT."inc/datahandlers/post.php";
			$posthandler = new PostDataHandler("insert");
		$msg = intval($reputation_value)."reputes added.";
		$post = array(
			"tid" => $tid,
			"replyto" => "1",
			"fid" => $fid,
			"subject" => $thread['subject'],
			"icon" => $thread['icon'],
			"uid" => $user['uid'],
			"username" => $user['username'],
			"dateline" => TIME_NOW + 1,
			"message" => $msg,
			"ipaddress" => get_ip(),
			"posthash" => $mybb->input['posthash']
		);
			if($mybb->input['pid'])
			{
			$post['pid'] = $mybb->input['pid'];
			}
			$post['options'] = array(
			"signature" => "0",
			"subscriptionmethod" => "0",
			"disablesmilies" => "0"
		);
		$posthandler->set_data($post);	
		$valid_post = $posthandler->validate_post();
			if(!$valid_post)
			{
				$post_errors = $posthandler->get_friendly_errors();
			}
		$postinfo = $posthandler->insert_post();
		$last_thread = array(
			"lastposter" => $user['username'],
			"lastposteruid" => $user['uid']
		);
		$db->update_query("threads", $last_thread, "tid = '".$tid."'");
		$last_forum = array(
			"lastposter" => $user['username'],
			"lastposteruid" => $user['uid']
		);
		$db->update_query("forums", $last_forum, "fid = '".$fid."'");

Can anyone help me to correct this ?

I solved myself Smile