PDA

View Full Version : Update field on new post?


Kaitlyn2004
02-12-2009, 01:50 PM
I added a field to the post table and in hook postdata_save, I have (trimmed down for display):

$this->validfields['myfield'] = array(TYPE_INT, REQ_NO);
$this->set('myfield', 1);


This works just fine, HOWEVER it doesn't work on a new thread post (first post).

It looks like there is threadfpdata_presave but if I do the same thing, it wants to add that field to the thread. I don't have any fields in the thread table or want to alter it, so how do I accomplish this?

thanks!

Dismounted
02-13-2009, 08:09 AM
Setting data in postsave won't save it to the database. By that time, the data has already been updated/created in the database, and you are working with post-processing tasks. You can just update the database with the DB object at postsave:

Whoops, read the hook wrongly. :p You should have a look at the ThreadPost Data Manager as well (there are a few DMs in that one file).