• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Call function if Admin Option Changes?

alexp999

Active member
#1
Hi,

I am working on an add-on and would like to clear out a cache directory if a setting changes.

I have seen that you can run a validation callback, is it possible to use this to determine if the value has changed?

i.e. I don't want to clear the cache directory everytime someone presses save in the ACP settings, only if this specific settings value has changed.
 

Chris D

XenForo developer
Staff member
#4
You have access to the $dw object, see XenForo_Option_TemplateFiles for an example.

You can do: $dw->getExisting('option_value') and compare that to $option or simply, $dw->isChanged('option_value');
 
Last edited:

alexp999

Active member
#5
isChanged didn't seem to work, but getExisting did, so I have been able to create an if statement which does what I want.

Thanks for the help. :)