I am migrating a 15,000+ users from a site's old CMS (WP), and have them set to Pending. All of their user information will be created and on Craft CMS, except their passwords will not be set, as migrating that is too complicated (for what I can tell.) So, the process I have in mind for previous users to login is:

  1. User enters Username/Email & PW, submits login form.
  2. Form sends data to custom Custom Plugin Controller, and follows logic:

    1. If user status==active, simply send form data to Craft's users/login and proceed as usual.

    2. If user status==pending:

      1. Check if username/email exists in previous users list.

        1. If it does not, simply send form data to Craft's users/login and proceed as usual.
        2. If it does exist, it sends the Activation Email and redirects to special URL stating "You've been sent an email to re-activate your account on this new website."

Is this possible to do? It would be fairly straight forward to write, except I am unsure if there is a way to communicate with Craft's users/login via a plugin. Is it something like craft()->users->login( $userNameOrEmail, $userPassword )?

I'm aware I could also just send out batch email activation links to the migrated users, but I'd much prefer this method, in case they miss those e-mails and try logging in at a future date. Alternatively I could have a "Are you a user of the old site? Click here to re-activate your account." Link on the login page, but again users may not notice it and think they cant login anymore.

Any help would be hugely appreciated! Thanks.

2 Answers 2


What you're attempting to do is very doable. This should be of help to you:


You can use the Yii forward function to pass along a request to another action handler:

    $this->forward('users/sendNewEmailVerifyEmail', false);
  • I thought for sure this would be a lost cause. $this->forward() accomplished EXACTLY what I needed. Thank you!!
    – taylor
    Dec 4, 2015 at 7:48

For those that come looking for the answer about logging in by service without the rest of the context of the question.

See UserSession service docs: https://craftcms.com/classreference/services/UserSessionService#login-detail

Login with user/password:

craft()->userSession->login($username, $password, $rememberMe = false);

Or when you have already authenticated and simply wish to login:

craft()->userSession->loginByUserId($userId, $rememberMe = false, $setUsernameCookie = false);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.