Hello,

I am using LoginToboggan and when a user registers and logged in via Immediate Login option, two messages appear (screenshot attached):

1) A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message.
2) Registration successful. You are now logged in.

I am wondering why the #2 appears and if it is possible to not show it? If it is a message of core drupal, should LoginToboggan be overriding it to not show it as registration is actually not successful yet as the user still needs to validate?

I hope someone will be able to help.

Thank you!

Comments

hunmonk’s picture

Status: Active » Postponed (maintainer needs more info)

#2 is a core message, and should never be displayed -- LT is overriding the functionality of user module for registration purposes, so user_register_submit(), the function that displays that message, should never be called.

i've check locally, and it's working properly -- so my guess is that you have another contrib module installed that's gumming up the works. disable all other contribs and see if the problem persists. if it does not, then start turning on the other contribs one at a time until you find the culprit.

YK85’s picture

thanks! i will begin testing one module at a time to see which is causing this.

YK85’s picture

Status: Postponed (maintainer needs more info) » Active

Hello,

I found that Email Registration module was causing the issue
http://drupal.org/project/email_registration

with email registration enabled:

・A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message. 
・Registration successful. You are now logged in. 

with email registration disabled:

・A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message. 

As I already had this post open, I was hoping to start here to see if there is something LoginToboggan can do to better integrate with Email Registration module? I would really appreciate your help!

Thank you!

EDIT: I opened #791306: Compatibility issue with LoginToboggan module in the Email Registration queue.

hunmonk’s picture

Status: Active » Closed (won't fix)

i don't put in custom hacks for other modules. looks like this should be addressed in the email registration module.

YK85’s picture

sorry, I didn't mean to imply a custom hack to make Email Registration module work.
If you may have any idea of what might be causing this issue, your help would be awesome!
(also, the email registration module queue is pretty inactive by maintainers it seems)
Thanks for the great module!

YK85’s picture

The below code looks to be what is triggering this in Email Registration module.
To what code in LoginToboggan module may I point the maintainers to fix this issue?

function custom_email_registration_name_submit($form, &$form_state) {
  if (!isset($form_state['user'])) {
    return;
  }

  $admin = user_access('administer users');
  $account = $form_state['user'];

  if (!variable_get('user_email_verification', TRUE) && $account->status && !$admin) {
    // No e-mail verification is required, create new user account, and login
    // user immediately.
    $auth = array(
      'pass' => $form_state['values']['pass'],
      'name' => $account->name,
    );
    if (user_authenticate($auth)) {
      // Authenticated, add a message and go to the users account
      // Since the standard workflow doesn't work, no other messages should appear.
      drupal_set_message(t('Registration successful. You are now logged in.'));
      $form_state['redirect'] = 'user/'. $account->uid;
    }
  }
}

In drupal core there is user_register_submit

if (user_authenticate(array_merge($form_state['values'], $merge_data))) {
        drupal_set_message(t('Registration successful. You are now logged in.'));
      }
hunmonk’s picture

Project: LoginToboggan » Email Registration
Status: Closed (won't fix) » Active

the extra submit handler was an attempt to fix #648450: No e-mail verification required autologin.

IMO the workflow of the email_registration module is sub-optimal, and that patch was an attempt to work around the sub-optimal workflow.

a much better fix for this whole situation is to move the logic in the hook_user 'insert' op into a form validation handler for the registration form. there you can set the value of the username in the form itself, so that the module will play more nicely with core's registration submit function -- and you can rip out the custom submit handler in the module.

while it might seem evil to manipulate form values in a validate handler, it's actually a fairly common practice in cases like this -- and it's much less evil than the current approach ;)

Bilmar’s picture

subscribing - I was able to replicate and hoping this issue can be fixed.
I am available for any testing needed in troubleshooting.

Bilmar’s picture

Title: Registration successful. You are now logged in. » Submit Handler causing issues
Category: support » bug

I changed the title to better fit the issue and category as bug report.
#791306: Compatibility issue with LoginToboggan module looks to be a duplicate.

I hope someone will be able to help by looking at hunmonk's comment at #7 and look into a fix for this issue. Please let me know if I can help with any testing. Thank you very much.

rburgundy’s picture

Another issue: #816572: immediate login happens even after unchecking - Forces Immediate Login when Email Registration module is enabled. Disabling Email Registration properly allows not immediately logging in the user when the option is unchecked in LoginToboggan settings.

I believe this is the code in Email Registration.

/**
 * Custom submit handler to fix redirect for immediate logins
 * #648450
 *
 */
function custom_email_registration_name_submit($form, &$form_state) {
  if (!isset($form_state['user'])) {
    return;
  }

  $admin = user_access('administer users');
  $account = $form_state['user'];

  if (!variable_get('user_email_verification', TRUE) && $account->status && !$admin) {
    // No e-mail verification is required, create new user account, and login
    // user immediately.
    $auth = array(
      'pass' => $form_state['values']['pass'],
      'name' => $account->name,
    );
    if (user_authenticate($auth)) {
      // Authenticated, add a message and go to the users account
      // Since the standard workflow doesn't work, no other messages should appear.
      drupal_set_message(t('Registration successful. You are now logged in.'));
      $form_state['redirect'] = 'user/'. $account->uid;
    }
  }
}
rjbrown99’s picture

I think I can explain at least some of what is going on with logintoboggan and the submit handlers, specifically as it relates to this issue and commit: #648450: No e-mail verification required autologin.

More specifically and at least in my case, I was using the "Redirections" feature of logintoboggan, found in /admin/user/logintoboggan under the "Redirect path on Registration" header. This allowed me to redirect new users to the front page after an immediate logon instead of taking them to their profile page. In my case, I am using immediate logon and have specified in there to take users to my front page.

One of the things logintoboggan does is to replace the submit handler for the core registration function. Here's what it ends up looking like when you are using both logintoboggan and this module:

    [#submit] => Array
        (   
            [0] => logintoboggan_user_register_submit
            [1] => custom_email_registration_name_submit
        )

OK, so the ordering of the submit handlers goes first to logintoboggan and then to custom_email_registration. Here's what the $form_state['redirect'] looks like after logintoboggan is done, and before custom_email_registration runs:

    [redirect] => Array
        (  
            [path] => <front>
            [query] =>
            [fragment] =>
        )

... which in my case is correct. I want it to go to the front page. But when you look at what the above issue/patch introduced to email_registration, it runs through this if statement in the new submit handler:

    if (user_authenticate($auth)) {
      // Authenticated, add a message and go to the users account
      // Since the standard workflow doesn't work, no other messages should appear.
      drupal_set_message(t('Registration successful. You are now logged in.'));
      $form_state['redirect'] = 'user/'. $account->uid;
    }

... and that redirects the user to their profile, which is not what I wanted to have happen.

I have backed out to the previous -dev version of this module for now. What would you suggest in terms of fixing this? Would you care to add a module_exists for logintoboggan so that if statement isn't called when you are using that module? Or something else? I'm happy to roll a patch, just looking to agree on an approach.

Thanks and I hope that all makes sense.

rjbrown99’s picture

Title: Submit Handler causing issues » Conflict with LoginToboggan submit handler
rburgundy’s picture

rjbrown99 - would you happen to know what hunmonk is recommending?

a much better fix for this whole situation is to move the logic in the hook_user 'insert' op into a form validation handler for the registration form. there you can set the value of the username in the form itself, so that the module will play more nicely with core's registration submit function -- and you can rip out the custom submit handler in the module.

rjbrown99’s picture

I understand and I'll try to explain.

There are two handlers at play here - one for validating a form before it is submitted, and then a second submit handler that is called after validation and during the submit process. There can be more than one handler for each action, so you could have 1 or more validations and one or more submits. That's how you see the array I linked above where it has two submit handlers which are called in order.

What hunmonk is suggesting is to move the code in #648450: No e-mail verification required autologin from the submit handler into a validation handler. This would mean it's called before you ever get to submit and it presents less potential for conflict with logintoboggan or other modules. If you do it at the validation level it would fail before it ever gets to a submit handler.

I don't have the problem from that issue because I am not using those features. If you aren't either, you can back out to the previous version by reviewing the commit that introduced the submit handler:
http://drupalcode.org/viewvc/drupal/contributions/modules/email_registra...

Get rid of the stuff in green and modify the stuff in yellow back to the previous version.

YK85’s picture

Hi rjbrown99,

I removed all the green highlighted code and modified the yellow back, but the user still gets logged in immediately after registering. In LoginToboggan I have the path set to /auth where there is a page with detailed instructions. When I disable Email Registration module and try again it properly redirects to /auth without logging in the user.

I've tested it 3 times where enabling Email Registration (with reverting http://drupalcode.org/viewvc/drupal/contributions/modules/email_registra...) makes user immediately login but with Email Registration disabled, it works properly and doesn't log in user and redirects to /auth

Would you happen to have any idea what may be causing this?

Thanks!

scotjam’s picture

Hi yaz085

I've got the same problem. Were you able to resolve this?

cheers
scotjam

Balbo’s picture

+1 following this thread...

YK85’s picture

I unfortunately have not found a solution yet =(

scotjam’s picture

Hi yaz085

Is this a potential workaround?

Use string override module to hide the message 'Registration successful. You are now logged in. '?

This is what I've done.

cheers
scotjam

YK85’s picture

Unfortunately no bc this is also causing other issues as mentioned in #10 =(

dudabone’s picture

Well, after banging my head against the wall I was able to get a non-elegant (yet effective) solution for #10 (immediate login happens even after unchecking). after preforming the changes as descirbed in #14, you also need to remove/comment these lines:

if (!variable_get('user_email_verification', 1) && $user->uid == 0) {
$user = $account;
$user->name = $namenew;
}
$account->name = $namenew;

YK85’s picture

Thanks dudabone!

For temporary solution I commented out:

$form['#submit'][] = 'custom_email_registration_name_submit';

and also commented out:

if (!variable_get('user_email_verification', 1) && $user->uid == 0) {
$user = $account;
$user->name = $namenew;
}
$account->name = $namenew;

I hope someone may be able to look into this for a permanent fix for Email Registration module.
Thanks

DanaRoseRoss’s picture

StatusFileSize
new805 bytes

PLEASE IGNORE

DanaRoseRoss’s picture

StatusFileSize
new980 bytes

Changes from #22 as a patch.

chuckbar77’s picture

Has there been any development on improving Email Registration module to work with other modules?

Bilmar’s picture

@chuckbar77 - the patch in #24 is the temporary solution
We must wait patiently for someone with programming skills to help with this problem =)

bleen’s picture

subscribing

thepanz’s picture

I'm further investigating this issue: to me the "email_registration" could be seen as a sub-feature of LoginToboggan.. is there any interest in merging the two modules?

Bilmar’s picture

http://drupal.org/node/596300

Maintainer says "let me make it clear that i have no intention of merging Email Registration with LT -- it's not functionality that i am interested in supporting... :)"

thepanz’s picture

Thank you for your link.. I'm not with the maintainer reply, but if it's his will ... we can't to nothing more! :(
LT maintainer also sentenced that 6.x code is in "code freeze" (besides bug-fixes) here :#979706-1: More Clean code: adding logintoboggan.admin.inc file.

I'm thinking about a *new* module with all the SignOn/LogIn features and enhancements from the two modules. They (LoginToboggan and EmailRegistration) deal with the same user-data in almost the same place, why should they reside as two separate (and fighting) modules? :)

What do you think?

YK85’s picture

I'd definitely help with testing if a new module is introduced (especially as this module is not maintained and LT is not interested in functionality)

greggles’s picture

I do not think it makes sense to combine this module with login toboggan.

login toboggan is a great module for what it does, but part of why I chose and worked on this module was because login toboggan introduced some bugs while this module was relatively simple.

awolfey’s picture

StatusFileSize
new982 bytes

I would rather see ER and LT work this out, but in the meantime I just made a simple module that undoes the conflict by unsetting the ER user registration submit function.

This eliminates ER from signing in a user a second time when using immediate login.

I'm hoping this isn't a permament problem, but in the mean time you can use this without have to hack LT or ER.

chuckbar77’s picture

subscribing - I hope Email Registration and Logintoboggan modules can play nice together in the future.
What about #33 as a patch into Email Registration, where it unsets when it detects Logintoboggan module enabled?

tfo’s picture

+1

Would love to see a comment from the maintainer about whether the patch in #24 is relevant to his goals for the module.

Emmanuel.masanche’s picture

Project: Email Registration » LoginToboggan
Version: 6.x-1.x-dev » 6.x-1.8
Assigned: Unassigned » Emmanuel.masanche
Priority: Normal » Major
StatusFileSize
new400.88 KB
new414.07 KB

help me with this! i use logintoboggan and organic groups profile modules.
the problem is when login toboggan is in "set password " for registration.on clicking join group link ....after filling the og fields ....on submit ......the error message "you must enter a password " appears!any one with any ideas of what might b the ....... there is no password field in og profile fields!!help me!

bleen’s picture

Project: LoginToboggan » Email Registration
Version: 6.x-1.8 » 6.x-1.x-dev
Assigned: Emmanuel.masanche » Unassigned
Priority: Major » Normal

Emmanuel, please do not change the meta data around this issue and especially do not assign it to yourself unless you plan to fix it.

Emmanuel.masanche’s picture

I understand! i didnt mean to assign it to my self!thought may be here people will help!so where shud i adress this issue? bleen18

rjbrown99’s picture

#38 this issue is specifically related to a bug in the email registration module that has to do with a submit handler. If you are having a different issue, you should open a new issue in the issue queue. Rather than a plea for help, it would be best to include as much information as is possible about the issue.

Here's the guide about how to file an issue. I suggest starting there as it may help you in obtaining support.
http://drupal.org/node/73179

Emmanuel.masanche’s picture

sorry for putting this here! i fixed it !

botanic_spark’s picture

Thanks dudabone!
Solution in #21 worked for me :)

greggles’s picture

Status: Active » Needs work

Regarding patch #24 -

I don't see how we can do this:

-      $form['#submit'][] = 'custom_email_registration_name_submit';
greggles’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Email Registration is no longer supported on 6.x-1.x. If you feel this issue is still relevant for 7.x or 8.x and is not a duplicate of another issue, please reopen it.