Back to vBulletin 3 Articles

How to update thread field on new post
by -=Sniper=- 29 Jun 2006

I think this should help someone, I posted this as a question but now have it working.

First add the field foobar to the threads table (as an example). This is true/false based field, you will have to add your own checks, e.g who can update foobar etc

In the quick reply/new reply template/s add this HTML in the thread management area quick reply area

HTML Code:
<label for="qr_foobar"><input type="checkbox" name="foobar" value="1" id="qr_foobar" accesskey="w" tabindex="4" />Please update my Foobar</label>
In threaddata_start

PHP Code:
$this->validfields['foobar'] = array(TYPE_BOOLREQ_NO); 
In newpost_complete

PHP Code:
$set_foobar_status false;
    if (
$vbulletin->GPC['foobar'])
    {
        
$set_foobar_status true;
    }
    if (
$set_foobar_status)
    {
        
$thread =& datamanager_init('Thread'$vbulletinERRTYPE_SILENT'threadpost');
        if (
$type == 'thread')
        {
            
$thread->set_existing($dataman->thread);
        }
        else
        {
            
$thread->set_existing($threadinfo);
        }

        if (
$set_foobar_status)
        {
            
$thread->set('foobar', ($thread->fetch_field('foobar') == 1));
        }
        
        
$thread->save();
    } 
In newreply_post_start

PHP Code:
$vbulletin->input->clean_array_gpc('p', array('foobar' => TYPE_BOOL));
$newpost['foobar'] =& $vbulletin->GPC['foobar']; 
I hope this helps, the advanced coders please improve if needed

vblts.ru supports vBulletin®, 2022-2024