Updating a user's data when a message is posted/deleted

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
Lamasticot bleu
Registered User
Posts: 2
Joined: Sun Sep 06, 2015 7:21 pm

Updating a user's data when a message is posted/deleted

Post by Lamasticot bleu » Sun Sep 06, 2015 7:28 pm

Hi all,

I'm writing an extension and one of the features requires that some of the user's fields be updated when they post a message (or when one of their messages is removed).

I have found events such as core.submit_post_end and core.delete_posts_after which are indeed called upon posting/deletion but I cannot find a way to add new fields to those normally updated in such actions (e.g. post count).

The forum sometimes sees more than 30k posts in a day so it has to happen in the same query that increments post count and updates other data for obvious performance reasons.

Is there any way to achieve this in 3.1?

Thanks!

Lamasticot bleu
Registered User
Posts: 2
Joined: Sun Sep 06, 2015 7:21 pm

Re: Updating a user's data when a message is posted/deleted

Post by Lamasticot bleu » Sun Sep 06, 2015 9:55 pm

Found the answer by looking at the source code (functions_posting.php).

One can use core.submit_post_modify_sql_data and do the following:

Code: Select all

		$sql_data = $event['sql_data'];
		$sql_data[USERS_TABLE]['stat'][] = 'user_something = whatever'
		$event['sql_data'] = $sql_data;

Post Reply

Return to “Extension Writers Discussion”