Adding dropdown to newthread
#21
the content of $handler will vary depending on what you are doing and what hook you are running. also, you should be able to use the $mybb->input instead

$plugins->add_hook("datahandler_post_validate_thread", "support_thread_validateforum");

function support_thread_validateforum(&$handler)
    {
        global $mybb;
        $display = false;

       // print_r($handler);
        //die();
        //get usergroups from settings
        $forumArr = explode(",","1,2");
        $groupArr = explode(",", "1,2");
        
        $post = $handler->data;

        if (in_array($post['fid'],$forumArr))
        {
            //current forum is a support forum
            //is the user required to enter a forum?
            if (!in_array($mybb->user['usergroup'],$groupArr))
            {
                //this user isn't exempt
                $display = true;            
            }
            
        }
        
        if ($display == true)
        {
            if ((int)$mybb->input['forumsubject'] == 0)
            {
             $handler->set_error("you did not pick a forum");
             return false; 
            }
        }
        /*echo $display;
        print_r($mybb);
        print_r($mybb->input);
        die();*/
    } 
Lost interest, sold my sites, will browse here once in a while. It's been fun.
Reply
#22
Yup that worked Big Grin

Now, how would I make it so that the information is added to the threads table? I want to add it into an extra column I made called "forumsubject" Smile
Reply
#23
Bump Smile
Reply
#24
$plugins->add_hook("datahandler_post_insert_thread", "your_functon"); //new thread

function your_function(&$handler)
{
	global $mybb, $db;
	$handler->thread_insert_data['forumsubject'] = $db->escape_string($mybb->input['forumsubject']);
}	
Lost interest, sold my sites, will browse here once in a while. It's been fun.
Reply
#25
Thanks Pavemen Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)