XF 2.0 Listener for option changes

Komposten

Member
Hi!

Is there a way to listen for changes to options? Currently I'm using a validation callback, but that feels like a hack since I'm making changes to the database/entities based on the change of the option (i.e. it's not validation stuff).

Regards,
Komposten
 
Why would you listen for options? You already know what values an option can take, so just catch every case.
 
The option is a user name input. I want to know when it is changed so that I can make changes to existing entries in the database (potentially hundreds of entities).
 
Why :unsure:? That's not what options are meant to be used for. You could extend the form save process and check for changed values and then again inject your code changing mechanism.
But really, you should just create another controller method which picks the username from a field and then executes your code. Pretty similar to as rebuilding caches etc work.
 
The idea is that posting in specific forums/threads should automatically change the author of the post. In my case this is about anonymisation of posts, but it could also be used for other use cases.

The new author is always the same, hence I added an option for it. When that option is changed I want to update the previous posts so that they all get the new author. What other choice is there for a global option like this?
 
I really wouldn't do that, it's inconsistent with other stock XenForo behaviour:
  • If you change the destination forum for reported posts, posts reported prior to this change will stay in the previously configured forum
  • If you change the author, title or message of the welcome converstion, existing welcome conversations will stay as they are
  • and so on
If you really think such a feaure is necessary, I'd implement it as as a cache rebuild as already suggested.
 
I really wouldn't do that, it's inconsistent with other stock XenForo behaviour:
  • If you change the destination forum for reported posts, posts reported prior to this change will stay in the previously configured forum
  • If you change the author, title or message of the welcome converstion, existing welcome conversations will stay as they are
  • and so on
If you really think such a feaure is necessary, I'd implement it as as a cache rebuild as already suggested.
Ah, if that's the standard then that's what I'll adhere to. Thank you both for your answers. :)
 
Back
Top Bottom