WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a plugin, and it has a function that takes two args, like so:

process($tokens, $payloads);

... would this work? :

add_action ( 'publish_post', process($tokens, $payloads) );

Many thanks!

share|improve this question
up vote 1 down vote accepted

No, this cannot work. Haven't you tested your idea?

A simple workaround would be a class:

class WPSE_53453_Action_Handler 
    public $tokens, $payloads;
    public function process() 
        $tokens   = $this->tokens;
        $payloads = $this->payloads;
        // do something awesome

$WPSE_53453           = new WPSE_53453_Action_Handler;
$WPSE_53453->tokens   = array ( 'foo', 'bar' );
$WPSE_53453->payloads = 'hello';

add_action( 'publish_post', array ( $WPSE_53453, 'process' ) );
share|improve this answer
Doesn't work. This is what I have: pastie.org/3979115 – Nimbuz May 27 '12 at 21:23
Your code doesn't do anything. What did you expect? – toscho May 27 '12 at 21:29
Ah no, I replaced the actual code with "do something" just to remove the unnecessary parts. – Nimbuz May 27 '12 at 21:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.