3

I have around 200 hundred users for an intranet setup on the Craft Users section all as pending status. Is there a way to send an activation email en-mass to all pending users? Rather than having to run through each user one at a time.

The system is set to change over and each user will need to verify their account and set their password, but they've been added to the system in advance and need to be sent an activation email out of hours so that they Intranet system changes overnight and they have an email waiting for them the next day they step into the office.

5
foreach(\craft\elements\User::find()->status('pending')->all() as $user){ 
    Craft::$app->getUsers()->sendActivationEmail($user);
}

Fetch all pending users and send them the mail

  • To clarify for anyone landing here via Google: the solution here is a code snippet to be applied as a plugin - which you'd need to make yourself. There is no built in action in the CMS to do as requested, and the above line is not Twig code to be put in a template. – Matt Wilcox Jul 2 '18 at 8:05
  • @MattWilcox To clarify, it can be done in Twig as well – Robin Schambach Jul 2 '18 at 8:06

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.