Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
394 views
in Q2A Core by
Hello, I'm writing a tracking plugin, and I would like it to function this way:

When a user posts a new question, it will surely CREATE a new record in qa_posts table. At the same time, I would like this action will also UPDATE another table (for example qa_tracker) with several input information like postid, post type, userid, post title, post content.

Where should I edit the core file so that the asking activity will do 2 jobs? Which function or which routing pages?
Q2A version: 1.8.5
by
+1
You can make use of events in Q2A. q_post event can be checked and required action be performed there.
by
Thanks.

I've just checked but the wildest thing is when a post is updated, it's also reported as q_post event. I don't want those updated questions, just newly-created ones.

If only core developers separated those two events. Haizzzzzzzz
by
+1
Or maybe I'm wrong, "post update" is somewhat post moderation process, because I see there is also q_edit event.

1 Answer

0 votes
by
edited by

For future reference

public function process_event($event, $userId, $handle, $cookieId, $params) {
        if ($event === 'q_post') {
qa_db_query_sub('
UPDATE `qa_tracker` SET `userid`=#,  `postid`=#,`title`=$,`content`=$',
 $userId, $params['postid'], $params['title'], $params['content']);

                              }
}

...