• viperfunk

    (@viperfunk)


    I have a question about the “priority” value passed to addAction().

    While the documentation reads “Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.”

    My question is, how do I find out the existing order of priorities for an action? Say “login” ? If I want something to happen when the username is checked, what priority value is that? How about right before the username is checked, or right after the password is checked?

    Is there somewhere that lists this information?

    Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Here is a great way to check out which functions are hooked onto a filter.

    A similar solution for actions would be:

    function print_actions_for( $action = '' ) {
        global $wp_actions;
        if( empty( $action ) || !isset( $wp_actions[$action ] ) )
            return;
    
        print '<pre>';
        print_r( $wp_actions[$action] );
        print '</pre>';
    }

    And use it by calling:

    print_actions_for( 'wp_head' );

    Thread Starter viperfunk

    (@viperfunk)

    Nice one, going to have to give that a go. Cheers 🙂

    Actually, I just tested it and it prints ‘1’ for true or ‘0’ for false! :-/

    This works:

    function var_dump_actions_for( $action = '' ) {
        global $wp_actions;
        if( empty( $action ) || !isset( $wp_actions[$action ] ) )
            return;
    
        var_dump( $wp_actions[$action] );
    }

    …and call using: var_dump_actions_for( 'wp_head' );

    Wait! No it doesn’t…

    …hang on…

    Ah, here it is. Just do this:

    var_dump( $wp_filter );

    That lists all of the filters and action hooks. The keys in the arrays look like the priorities for each hooked function.

    Also see this article.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘priority’ is closed to new replies.