Random New User Password Generator for WordPress

Inspired by https://wordpress.org/extend/ideas/topic/random-password-for-new-users WordPress plugin idea, and a bit of time on my hands, I decided to code up a simple little plugin that is easy to understand and use.

Random User Passwords In WordPress

Meet the Random New User Passwords for WordPress plugin. It’s a minimum viable solution, with zero-configuration, so don’t expect much.

Plugin approval status: approved and ready for download.

How it works

The plugin enqueues its script and stylesheet on the wp-admin/user-new.php page. A convenient filter that can be hooked to output error messages is show_password_fields. Although filters should not have side-effect, big no-no, I have chosen to break the rule.

There are two possible errors. One when no JavaScript is enabled, another when show_password_fields is hooked by some plugin or theme that disables the password fields. In the future, Random New User Password will probably use this hook to provide deeper features.

The JavaScript is simple as well. It uses easy-to-understand jQuery selectors to modify the password fields and check the “Send this password to the new user by email.” checkbox, because in 99% of cases admins will want to do that either way, and in 10% or those 99% cases they’ll will forget to check it, no?

The pseudo-random password generator is simple as well (should have called the plugin Simple Random New User Password instead), with the current character set of a-Z0-9, which is enough in most cases it generates a, what appears to be, random string, which is fed into the password fields thereafter.

The plugin is l10n-ready, with just 3 strings to translate.

Further thoughts

What should the next steps be?

  • No JavaScript, thank you! Let’s put a checkbox and the password is generated inside of PHP.
  • Where are the settings? Password length, character set, prefix.
  • Generate temporary passwords to force users to change once they’re in (hopefully not to 12345678 or password)
  • More buttons and sexier name!
  • Profit

Let me know what you think; is it useful? Are you using it? Would you like to contribute some ideas or maybe code? Feel free to issue pull requests to the plugin on github; will add you to contributors in SVN once we get approved in the WordPress.org repo.

Update

Turns out there’s been something similar already: Simple User Password Generator… is there any plugin that hasn’t been coded yet? 🙂

P.S. Props to @1Popol for the random dice icon.