2010-08-29, 05:11 AM
I'm trying to develop a plugin for MyBB that will take a new topic posted in a forum (let's call this Forum #1 with an ID of 91), and copy it over into another forum (Forum #2 with an ID of 92). When I try to use the only function documented to copy posts (Moderation::move_posts), it'll copy over the thread title, but not the actual thread or posts. Is there something I'm missing?
Plugin source for reference:
Plugin source for reference:
<?php
if(!defined("IN_MYBB")) {
die("Direct access isn't allowed!");
}
$plugins->add_hook("datahandler_post_insert_thread_post", "pmbr_newthread");
function pmbr_info() {
return array(
"name" => "Copy Posts",
"description" => "Copy a post from one forum to the other once posted",
"website" => "http://www.google.com/",
"author" => "Bionic",
"authorsite" => "http://www.google.com/",
"guid" => "",
"compatibility" => "14*"
);
}
function pmbr_newthread($threadbyref) {
global $mybb, $db;
$mythread = $threadbyref->post_insert_data;
if($mythread['tid']=="" || $mythread['fid']==""){
$thread = get_thread($mybb->input['tid']);
$mythread['tid'] = $thread['tid'];
$mythread['fid'] = $thread['fid'];
}
if($mythread['fid'] == "91") {
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_upload.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
$a = $moderation->move_thread($mythread['tid'], 92, "copy", 0);
}
}
?>