Support » Plugin: WP Crontrol » args in function

  • Resolved isarcowboy


    Hey John,

    could you give me an example how to grab args (array) in a function?
    I have added an array of args / attributes like [“mail-address”, 10] to my hook.
    How do I grab these args in my function?
    Best regards, Chris

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Blackbourn


    WordPress Core Developer

    Hi Chris,

    These args get passed as individual parameters to your callback function. Here’s an example callback for your cron event:

    add_action( 'my_action', function( $type, $number ) {
        echo $type;   // mail-address
        echo $number; // 10
    }, 10, 2 );

    Remember you’ll need to include the correct number for $accepted_args in add_action(), which in this case is 2.




    You made my day! excellent.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘args in function’ is closed to new replies.