array( 'type' => 'user', 'description' => t('Subscribe the user to all possible subscriptions'), 'configurable' => TRUE, 'hooks' => array( 'user' => array('insert', 'update'), ) ) ); } /** * A configurable Drupal action. Subscribe the user to a newsletter * hook = user: Subscribe this user to selected newsletter * * Available context: * $context['tid'] newsletter tid * $context['name'] newsletter name * * @see user_autosubscribe_subscribe_user_action_form() * @see user_autosubscribe_subscribe_user_action_submit() */ function user_autosubscribe_subscribe_user_action(&$object, $context = array()) { if ($context['hook'] == 'user') { $account = $context['form_values']; $fields = array( array('type' => 'type', 'value' => 'blog'), ); $methods = _notifications_send_methods(); $intervals = _notifications_send_intervals(); $subscription = array( 'type' => 'nodetype', 'uid' => $account['uid'], 'send_method' => $methods[0], 'send_interval' => '43200', //$intervals[0], 'fields' => $fields ); notifications_save_subscription($subscription); $fields = array( array('type' => 'type', 'value' => 'uudis'), ); $subscription = array( 'type' => 'nodetype', 'uid' => $account['uid'], 'send_method' => $methods[0], 'send_interval' => '43200', //$intervals[0], 'fields' => $fields ); notifications_save_subscription($subscription); $fields = array( array('type' => 'type', 'value' => 'event'), ); $subscription = array( 'type' => 'nodetype', 'uid' => $account['uid'], 'send_method' => $methods[0], 'send_interval' => '43200', //$intervals[0], 'fields' => $fields ); notifications_save_subscription($subscription); watchdog('action', 'User %name subscribed to newsletter %newsletter.', array('%name' => $account->name, '%newsletter' => $context['name'])); } } function user_autosubscribe_subscribe_user_action_form($context) { $form['newsletter'] = array( '#title' => t('Autosubscribe User'), '#description' => t('The newsletter series the user will be subscribed to.'), ); return $form; } function user_autosubscribe_subscribe_user_action_submit($form, $form_state) { $params = array( ); return $params; }