add_action inside of classes (2 posts)

  1. Ameisenman
    Posted 3 years ago #

    just a quick question about add_action() inside of classes:

    The use is like this:
    add_action('init', array(&$this, 'whatever_function') );

    But when you need to submit some more parameters like outside of classes:
    add_action('wp_head', 'some_function', 1, 10) (for example onyl)

    How do you do that inside a class? Like this:
    add_action('wp_head', array(&$this, 'some_function',), 1, 10 );
    Thanx in advance

  2. bcworkz
    Posted 3 years ago #

    I don't know about inside classes, it stands to reason the expanded form would still work as it does outside of a class. Perhaps the reason you're having trouble is you've reversed the priority and parameter count arguments? The form to add an action with 3 parameters with a priority of 10 will look like:
    add_action('wp_head', 'some_function', 10, 3);

Topic Closed

This topic has been closed to new replies.

About this Topic