Closed Llanilek closed 1 year ago
hi @Llanilek sorry for the late response,
It's a little bit difficult to give you a super accurate answer because you haven't supplied enough details for me to know which hook you are even referring to. I'm not even sure what you mean by "an addon's set_hooks"... do you mean the set_hooks()
method on a child class of EED_Module
or some other class?
Anyways, the best i can offer at the moment is some generic details pertaining to filters:
as I'm sure you know, you can only remove a filter after it has been registered and before it gets applied, so you need to know when the original filter was registered and when it is applied. Depending on the hook in question, it could be beneficial to remove the hook immediately after it was added or wait until the very last moment and remove it before it is applied.
if more than one callback is hooked into the same filter and you want to remove all of them, you can use remove_all_filters()
, but just like above when removing a single filter, you need to call that after all hooks have been registered and before they get applied.
dependening on whether the set_hooks()
method you are referring to is from a module or shortcode, will change when it is added.
Module hooks are set during the AHEE__EE_System__core_loaded_and_ready
hookpoint,
and shortcodes are set during AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons
.
Again, I don't know the specifics so I can't guarantee this will be correct, but you could try using the AHEE__EE_System__initialize
hookpoint, which comes after both of the above hookpoints, for removing the undesired hook.
Hope that helps
@tn3rb sorry yes I meant an EED_Module
We added our own version of one of the WP_Users SPCO module hooks but our addon's hooks were being registered first so both bits of code were running and causing a bit of a headache.
Good to know that we can hook into something to deregister.
Deregistering filters with remove_filter doesn't always work when called in an addon's set_hooks. If another addon is called after your addon that you're trying to deregister, the other addon just reregisters their hook.
Is there a better place to call a deregister after all addons have set their hooks/admin hooks?