I'm using the 'Set password & Immediate login' setting

I want to let pre-authorized users know that they have a limited access until fully authorized so i'm setting a warning message each time they log in. I'm doing this with the code below:

function preauthenticated_user($op, &$edit, &$user_edit, $category = NULL) {
	global $user;
	if ($op == 'login') {
              // the new role i've set for pre authenticated users is 'preauthenticated', this is rid 5
              if ($user->roles[5] == 'preauthenticated'){
				$message .= 'the message here';
				drupal_set_message(t($message));
    }
  }
}

This works fine and every time you log in without authenticating your email by clicking on the emailed link you get the above message. When you click on the link you get the 'You have successfully validated your e-mail address.' message, but also get the above message. All future logins are back to normal as an authenticated user and you don't get my custom message anymore.

It seems that as logintoboggan fires the 'You have successfully validated your e-mail address.' message it has not yet updated the user's role, so my custom message is also being set. Is there a way in which i can change my detection of pre-authenticated users so that it isn't set on the validation successful page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hunmonk’s picture

Status: Active » Needs review
FileSize
1.31 KB

try the attached patch and see if that fixes things up. if so i'll look into getting it committed to the module.

amcc’s picture

I've not patched the module yet - its a bit tricky as i've hacked a few things already, but i'll get round to doing it manually sometime. I did find a workaround though:

if ($user->roles[5] == 'preauthenticated' && arg(1) != 'validate'){
	//set the message here
}

As the confirmation link takes you to yoursite.com/user/validate, i don't fire the message on the validate page - you get instantly redirected from the validate page to where ever you asked the logintoboggan module to take you.

But cheers for the patch, as i'm sure there may be other issues that get affected by this

hunmonk’s picture

Title: add additional messages » remove pre auth, add auth user in $account object in email validation code
Version: 5.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed
FileSize
1.53 KB

attached has been committed to 5.x-1.x and 6.x-1.x, and should fix the problem described.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.