Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.