Attaches additional arguments to the currently executing event during queue processing. These args are stored on the event and can be retrieved by get_event_arg() in downstream step callbacks. Only works while the event queue is actively processing — returns false otherwise.
Parameters
| Parameter | Type | Description |
|---|---|---|
$args | array | Key/value pairs to attach to the current event. |
Return value
bool — true if the args were set, false if the queue is not currently processing.
Usage
// Inside a custom step's run() method
\Groundhogg\add_event_args( [
'order_id' => 1234,
'discount_code' => 'WELCOME10',
] );
Example
class My_Plugin_Lookup_Step extends \Groundhogg\Step {
/**
* Fetch order data and pass it forward to the next step.
*
* @param \Groundhogg\Contact $contact
* @param \Groundhogg\Event $event
*
* @return true
*/
public function run( $contact, $event ) {
$order = my_plugin_get_latest_order( $contact->get_email() );
if ( $order ) {
\Groundhogg\add_event_args( [
'order_id' => $order->id,
'order_total' => $order->total,
] );
}
return true;
}
}
Was this helpful?
Let us know if this document answered your question. That’s the only way we can improve.
