I've tried various Tasker solutions for this, but it doesn't work well for phones that are encrypted and secured with a password.
The closest thing I could find was a Tasker add-on that was given root permissions and disabled the password, unlocked, and re-enabled the password. At least, that's where my research led me, I could never get that to work.