Reputation: 7119
I may be missing something blindingly obvious here (I hope so).....I am creating a module in Drupal 6 that consists of some triggers and actions. in it's simplest form it consists of:
I would like as much as possible to be managed through the triggers / actions interface in Drupal as the site admin is not a developer. The plan is to use the cron trigger to fire the action in 1. which will then fire a trigger for each user. The site admin will then be able to create a Send Email action through the actions interface and hook it up to the trigger from 2.
The part I can't get my head around is how the recipient of the email will be specified - the user trigger will be fired from an action run by cron (i.e. not in any user context) - how can I pass in a variable that can be used here?
Thanks,
Upvotes: 1
Views: 2753
Reputation: 12177
Triggers fire actions not the other way around.
The user that you pass to actions_do dosn't have to be the logged in user. You can query for the users that you want to email and loop thrhough them doing user_load and then an actions_do
something like
foreach ($user_ids as $uid) {
$context_user = user_load(array('uid' => $uid));
$context = array(
'hook' => 'myhook',
'op' => $op,
'user' => $context_user,
);
actions_do(array_keys($aids), $context_user, $context);
}
Upvotes: 1