eventespresso / event-espresso-core

Event Espresso 4 Core for WordPress: Build an Event Ticketing Website Today!
https://eventespresso.com
GNU General Public License v3.0
121 stars 87 forks source link

remove_filter not working in set_hooks in addon. #4148

Closed Llanilek closed 1 year ago

Llanilek commented 1 year ago

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?

tn3rb commented 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:

Hope that helps

Llanilek commented 1 year ago

@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.