Right now it just stays on the same page, canceling it will just redisplay the form and submitting it will get me an access denied error.
Adding $form_values['redirect'] = '' to the function notifications_form_unsubscribe_confirm_submit() will make it redirects to front page.

Comments

fred0’s picture

Category: feature » bug
Priority: Normal » Critical

I am also having this problem. When the user is logged in, the form reloads, but since the unique link is now gone, I get the Access Denied and the "Your subscription has been removed." message. If the user is not logged in, I get Access Denied and an error that says "You may need to login below or register to access this page."
In both events, the unsubscription is successful, but the Access Denied is confusing the users to think that it failed.
I've had to remove the token from the emails and provide instructions on how to log in and where to go to change one's settings. This has also failed miserably since no one seems to read instructions very well. I am getting daily complaint emails because of this.
The fix in the original post is unclear and my attempts to use it failed.

ariflukito’s picture

Hi, sorry let me clarify the fix. In notification.pages.inc file inside the module directory, there is a function called notifications_form_unsubscribe_confirm_submit(). Inside that function just add the following line:
$form_values['redirect'] = '';
I set it empty so it will redirect to front page.

fred0’s picture

Yeah. I tried that. Put it both before the case t('Unsubscribe'): and inside of it to no avail.

/**
 * Process form submission
 */
function notifications_form_unsubscribe_confirm_submit($form, &$form_state) {
  $subscription = $form_state['values']['subscription'];
  switch ($form_state['values']['op']) {
    case t('Unsubscribe'):
      notifications_delete_subscription($subscription->sid);
      drupal_set_message(t('Your subscription has been removed.'));
      break;
    case t('Cancel'):
      // Do nothing, not worth showing a message, just get back
      break;
  } 
}
jose reyero’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Active » Fixed

Added some redirect to all these forms.

fred0’s picture

Status: Fixed » Needs work

Almost...
It works if you're logged in when you follow the link, but it still fails to Access Denied if the user is not logged in which is the more likely case for someone following a link from the email notification.

fred0’s picture

Status: Needs work » Closed (fixed)

Oops. Tested the wrong version. My bad. Ignore my last post.