Log in

View Full Version : userdata_postsave hook [PLEASE HELP]


Nullifi3d
01-19-2006, 10:56 PM
I managed to temporarily fix this by using different hooks and code, but now I have 3 different hooks for what could be done with one (I think).
- ajax_complete
- newreply_post_complete
- newthread_post_complete

Can anyone fix the code below to work with userdata_postsave (or another 1 hook solution):if ($type == 'thread') {
$this->registry->db->query_write("UPDATE " . TABLE_PREFIX . "banners SET available = available + 100 WHERE userid = " . $this->registry->userinfo['userid']);
} else {
$this->registry->db->query_write("UPDATE " . TABLE_PREFIX . "banners SET available = available + 10 WHERE userid = " . $this->registry->userinfo['userid']);
}
I am trying to update a mysql table with two different decimal values depending on whether the post is a reply or a new thread.

Marco van Herwaarden
01-20-2006, 10:58 AM
userdata_postsave is called whenever member/user information is changed, like when changing a profile.

The 'post' means that it is called after the new data is saved to the database. The 'presave' versions are called before data is written to the database.

This hook has nothing to do with posting.

Nullifi3d
01-20-2006, 12:07 PM
Andreas suggested that I use userdata_postsave instead of newpost_complete.

Edit: I changed the hook to newpost_complete and modified the variables in the query to make it work. Thread solved.