asprin
Active member
As part of an addon that I'm building, I would need to change the owner/author of every post (to some set defined user_id) whenever a new one is made and this should be applicable to only a specific forum (the forum_id will be taken from the ACP as part of addon's option). My solution to this is as follows:
1. Create a new
2. Use a hint of
3. In the static method, get the
4. Put the code to modify the post owner inside this
Is this a good approach or is there a better way of achieving the goal?
1. Create a new
entity_pre_save
code event listener2. Use a hint of
XF\Entity\Post
to restrict it to only posts3. In the static method, get the
forum_id
from the addon's options and use that inside an if
condition to ensure that the code runs only if the new post is being made in the specified forum (At this point, I'm not sure if I'll have access to that info)4. Put the code to modify the post owner inside this
if
blockIs this a good approach or is there a better way of achieving the goal?