function simplenews_subscriptions_admin_form_submit in Simplenews 7.2
Same name and namespace in other branches
- 6.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_submit()
- 7 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_submit()
FAPI ADMIN subscription form_submit.
1 string reference to 'simplenews_subscriptions_admin_form_submit'
- simplenews_subscriptions_admin_form in includes/
simplenews.subscription.inc - FAPI ADMIN subscription form.
File
- includes/
simplenews.subscription.inc, line 936 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_admin_form_submit($form, &$form_state) {
$subscriber = simplenews_subscriber_load_by_mail($form_state['values']['mail']);
// update subscriptions
arsort($form_state['values']['newsletters'], SORT_NUMERIC);
foreach ($form_state['values']['newsletters'] as $newsletter_id => $checked) {
if ($checked) {
simplenews_subscribe($form_state['values']['mail'], $newsletter_id, FALSE, 'website');
}
else {
simplenews_unsubscribe($form_state['values']['mail'], $newsletter_id, FALSE, 'website');
}
}
// update subscriber
$data = array();
$subscriber->activated = $form_state['values']['activated'];
if (!$subscriber->uid) {
if (isset($form_state['values']['language'])) {
$subscriber->language = $form_state['values']['language'];
}
}
simplenews_subscriber_save($subscriber);
drupal_set_message(t('The newsletter subscriptions for %mail have been updated.', array(
'%mail' => $form_state['values']['mail'],
)));
}