1
  • User account is "pending"
  • verificationCode is created in database, and erases when visiting the hyperlink.
  • I'm able to successfully produce an activation email using the code below:

Code:

$user = craft()->users->getUserByEmail($emailAddress);

if ($user->getStatus() != "active")
{
    craft()->users->sendActivationEmail($user);
  • I'm redirected to the page set for activateAccountSuccessPath in config/general.php which an account edit page.
  • I'm "sort of" half logged in... able to see the email address for my account filled in the edit profile form, but the CMS otherwise does not recognize me as logged in.

Any ideas?

  • This is all in the context of the front-end of the site? If you find that user's row in the craft_users table, are locked, suspended, pending all set to 0 and is there anything in the verificationCode, verificationCodeIssuedDate and unverifiedEmail columns? – Brad Bell Oct 31 '16 at 16:53
  • verificationCode and verificationCodeIssuedDate obtain a hash and the hash goes away after visiting the link. Visiting the link a second time (after the hash is deleted) results in a 404 link (which is expected). – Jarrett Barnett Oct 31 '16 at 17:48
  • "but the CMS otherwise does not recognize me as logged in." - how are you testing that? if you give the user "Access CP" permissions, can they log into the control panel? – Brad Bell Oct 31 '16 at 18:02
  • They would have access to their /edit/profile page on the front-end (and be able to see the data associated with their user account)... and any dynamic "login/logout" links were still showing "login" as if the user wasnt logged in... hence the "half logged in" ;) – Jarrett Barnett Oct 31 '16 at 18:07
1

After following the stack trace for activating a user (with the link), I discovered that activation fails at /craft/app/services/UsersService.php:822:

820:   public function verifyEmailForUser(UserModel $user)
821:   {
822:      if ($user->unverifiedEmail)
823:      {

Apparently I needed to set the unverifiedEmail property when creating "Pending" users via a plugin as opposed to only setting the 'pending' property to false.

$user = new UserModel();
$user->email = 'pendinguser@email.com;
// ... set other properties
$user->pending = false;
$user->unverifiedEmail = '';

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.