0

I would like to give my user the opportunity to register and login with username AND email.

Therefore I installed the module LoginToBoggan where you can enable that users can login using their e-mail address.

When you want users to set their password at registration you need to check the checkbox Set password. But when you do this you also get a mail to set your password (can only be used once).

But I don't want that. I just want them to register with email/username and directly login in without getting ANY email. I fire a rule to send a mail after I created an invoice so I don't want the drupal account emails.

But I didn't found out how I can simply do this?

1

I use the same type of setup as the one you describe:

  • Register and login with username and email.
  • Login using the email address.
  • User sets password upon registration (i.e. no email confirmation required).

I've found that the process where user receives a one-time link to set password is a huge stumbling block in the registration process.

Drupal let set up the site to have user sets password upon registration (Uncheck "Require e-mail verification when a visitor creates an account" on Administration » Configuration » People » Account settings).

However, I do not use LoginToBoggan to allow the users to login using the email address.

Instead, I use Realname Reg. Please note that this is a sandbox project, but it is actively maintaned (by me), and it has been tuned specifically for the use case you describe. I've used it on a dozen production sites for about a year with no issues.

  • Thanks, but I'm still getting the change password at registration mail after installing your module. What could be the problem of this? – nielsv May 23 '14 at 8:10
  • I did, but I'm still getting the mail. I register, I get logged in but I'm stil getting set password email – nielsv May 23 '14 at 8:13
  • I am unable to reproduce this. Btw, that setting is Drupal core - it has nothing to do with my module. At my sites, it works as intended. It must be some other module you've got installed that interferes with it. I suggest you set up a clean install of Drupal, and then enables this core feature and verfies that it works. Then install my module and verify that it still works. LoginToBoggan is the prime suspect for messig up this. Make sure you fully uninstall it (not just disable it). – Free Radical May 23 '14 at 8:21
  • And could I set it directly in the code (just extra, maybe it works) – nielsv May 23 '14 at 8:26
  • I've added this $conf['user_mail_register_no_approval_required_notify'] = FALSE; to my settings.php and now it works. Strange .. – nielsv May 23 '14 at 8:38
0

I faced the same problem a few days ago, I was using this logintoboggan module but didn't want my user to confirm emails, just register with password and login as well, so what I did is to remove the 'non-authenticate' user role from the user and add 'authenticate' role when the user login for the first time.

/**
 * Implements hook_user_login().
 */
function mymodule_user_login(&$edit, $account) {
  if (in_array('non authenticated user', $account->roles)) {
    // remove non-auth role from user object.
    _remove_role_from_user($uid, 'non authenticated user');
    // Add auth role to user object.
    _add_role_to_user($uid, 'authenticated user');
  }
}

function _add_role_to_user($user, $role_name) {

  // For convenience, we'll allow user ids as well as full user objects.
  if (is_numeric($user)) {
    $user = user_load($user);
  }
  // If the user doesn't already have the role, add the role to that user.
  $key = array_search($role_name, $user->roles);
  if ($key == FALSE) {
    // Get the rid from the roles table.
    $roles = user_roles(TRUE);
    $rid = array_search($role_name, $roles);
    if ($rid != FALSE) {
      $new_role[$rid] = $role_name;
      $all_roles = $user->roles + $new_role; // Add new role to existing roles.
      user_save($user, array('roles' => $all_roles));
    }
  }
}

function _remove_role_from_user($user, $role_name) {
  // For convenience, we'll allow user ids as well as full user objects.
  if (is_numeric($user)) {
    $user = user_load($user);
  }
  // Only remove the role if the user already has it.
  $key = array_search($role_name, $user->roles);
  if ($key == TRUE) {
    // Get the rid from the roles table.
    $roles = user_roles(TRUE);
    $rid = array_search($role_name, $roles);
    if ($rid != FALSE) {
      // Make a copy of the roles array, without the deleted one.
      $new_roles = array();
      foreach($user->roles as $id => $name) {
        if ($id != $rid) {
          $new_roles[$id] = $name;
        }
      }
      user_save($user, array('roles' => $new_roles));
    }
  }
}

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.