[wp-hackers] hooks & future posts
James Collins
james at om4.com.au
Sun Sep 20 23:52:03 UTC 2009
Hi Matt,
The default for add_action() / add_filter() is that it will pass 1 argument
to your function unless otherwise specified. So if you just do:
add_action('action_name', 'do_stuff');
Then do_stuff() will have be sent a single argument.
If the filter/action requires more than 1 argument, then you must manually
specify it like you've done:
add_action('action_name', 'do_stuff', 10, 3);
Regards,
James Collins
OM4 - Website Design and Development
OM4.com.au | OM4Tourism.com
2009/9/21 Matt Martz <matt at sivel.net>
> 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/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list