1

I have a simplenews registration block on my site. If people sign up for a newsletter, they receive a mail with a confirmation link. When they click on the link they come to a page with another confirmation button, which must be clicked if you realy want to register.

Thats the default behavior called Double-Opt-In in simplenews.

What I want for registration ist that you receive a mail with a confirmation link, if you click it you come to the page which says something like 'You are registered!'. I want to disable the need of this second button, any ideas?

Thanks in advance

1

You need override the functionality of the simplenews module. Modify the simplenews confirmation form with a custom module using hook_form_alter():

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'simplenews_confirm_add_form') {
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'mymodule') . '/simplenews_autosubmit.js',
    );
  }
}

Then create a JS file, simplenews_autosubmit.js in your custom module:

(function($) {
    window.setTimout(function(){ $('#simplenews-confirm-add-form').submit(); }, 3000);
})(jQuery);

You can set the 3000 to however long (in milliseconds) you want to wait between load and submit.

That should trigger a JS form submission upon loading the confirmation page.

  • Yeah that would work but I think this is a little bit dirty. I thought more of a hidden configuration or something... So another option would be to change a few lines in the module code, but this is dirty, too. – dba May 7 '15 at 8:42
  • 1
    If you want to go that route, you could probably use hook_form_alter() to adjust the simplenews setting form & hook_menu_alter() to override the confirmation form path. That might get you something more to your liking. I threw out this solution as a minimally intrusive altercation of simplenews's default behavior. – Shawn Conn May 7 '15 at 22:19
2

There's a considerably easier way to do this, which is also documented in the README.txt for 6.x-2.x, but apparently not in 7.x-1.x.

In short, just change the confirmation mail templates and append /ok to the URL token.

  • Any information if this also works in the 7.x version? – dba May 26 '15 at 7:40
  • Yes, I wouldn't have mentioned it if it didn't :) – Berdir May 26 '15 at 8:30
  • Oh Ok, i will try this way during this week, thank you very much :) – dba May 26 '15 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.