Hi,
I'm working on an add-on that changes the author of posts posted in specific threads, but there are a couple of things I haven't managed to figure out entirely:
Thank you,
Komposten
I'm working on an add-on that changes the author of posts posted in specific threads, but there are a couple of things I haven't managed to figure out entirely:
- Replying to a thread: Currently I'm using a code event listener for post_pre_save to edit replies before they are saved. This works well enough, but is there a better way? I have tried e.g. using Service\Thread\Replier->_save() and Service\Post\Preparer->afterInsert(), but in both cases the reply did not appear changed in the thread until after a refresh.
- Creating a new thread: In new threads of this type the author of the OP should also be changed. For this I'm using setupThreadCreate() and Service\Thread\Creator. It works fine, but is it the best way?
- Changing the author: Currently I change the post author by changing the user_id of the post entity, and then calling Thread->rebuildCounters() and Forum->rebuildLastPost(). However, this is obviously not enough as it doesn't update e.g. User->message_count and Thread->UserPosts. Is a manual update like this the way to go, or are there helper methods/classes to ensure everything linked to a post author (e.g. message counts) is updated properly?
Thank you,
Komposten