How to assign a parameter value to a rule upon creating rules scheduler task?

by Yakimkin Roman   Last Updated November 18, 2017 16:07 PM

I have a function which should be executed some time later. For example, in 3 months.

I've decided to do it using Rules and Rules Scheduler. I have created a Rule which executes php-code. And I'm trying to create a task for RulesScheduler, but the problem is I don't know how to assign a parameter to the Rule in the RulesScheduler.

$state = new RulesState();

    $state->addVariable('code', 'my_function("my_arg")', []);

    $now = new DateTime();
    $task = [
        'identifier' => $now->getTimestamp(),
        'date' => $now->getTimestamp()+60,
        'config' => 'my_rule',
        'data' => $state,
    ];

    rules_scheduler_schedule_task($task);

New task is created but there's an error upon executing. Could you clarify me, how to assign a parameter to the rule ?

Tags : 7 rules


Related Questions


Clone nodes and change fields with Rules and VBO

Updated May 20, 2015 20:03 PM