[wp-hackers] Prioritizing Function Hooks

Jesper Jarlskov jesper at jarlskov.dk
Wed Dec 7 15:59:34 UTC 2011


On Wed, Dec 7, 2011 at 4:56 PM, Mihai Chereji <mihai.chereji at gmail.com>wrote:

> On Wed 07 Dec 2011 05:47:35 PM EET, Alison Foxall wrote:
>
>> Hey All,
>>
>> I'm just starting out developing plugins and such had a question. How
>> would
>> you prioritize a function hook when the particular hook is used by
>> multiple
>> plugins?  e.g.
>>
>> Plugin One:
>>
>> add_action ("pre_user_query", "plugin_one_pre_user_query");
>>
>> Plugin Two:
>>
>> add_action ("pre_user_query", "plugin_two_pre_user_query");
>>
>>
>>
>> Thanks in advance!
>>
>> -A
>> ______________________________**_________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>
>
> As the Codex states (http://codex.wordpress.org/**
> Function_Reference/add_action<http://codex.wordpress.org/Function_Reference/add_action>
> )**, add_action accepts a 3rd optional parameter, called $priority, which
> defaults to 10.
>
> Perhaps counter-intuitively, the lower you set your priority, the earlier
> the action will be triggered.
>
> --
> -- Mihai Chereji
> ______________________________**_________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>

That actually makes sense.
This means that in case to actions overlap, the higher priority is run
later, and will overwrite the lower priority action.

-- 
Jesper Jarlskov


More information about the wp-hackers mailing list