[wp-hackers] hooks & future posts

Matt Martz matt at sivel.net
Sun Sep 20 16:24:34 UTC 2009


On Sun, Sep 20, 2009 at 05:13:31PM +0100, Peter Westwood wrote:
> <?php
> add_action('future_to_publish', 'do_stuff', 10, 1);
> function do_stuff( $in ) {
>  $f = fopen( dirname(__FILE__).'/log.log', 'a' );
>  fwrite( $f, "\nBefore\n" );
>  fwrite( $f, print_r($in, true) );
>  fwrite( $f, "\nAfter\n" );
>  fclose( $f );
>  return $in;
> }
> ?>

I think the key here is to notice that add_action/do_action by default does not
pass any arguments to your callback.  So to get it to pass any ammount
of arguments you need to specify that in your add_action, hence the
specification of '1' in Peter's example for add_action.

-- 
Matt Martz
matt at sivel.net
http://sivel.net/


More information about the wp-hackers mailing list