Support » Plugins and Hacks » Hacks » add_action inside of classes

  • Hello,
    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

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    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);

Viewing 1 replies (of 1 total)
  • The topic ‘add_action inside of classes’ is closed to new replies.