How to add a password generator to your WordPress

Once you start working with WordPress and begin to add new users, besides the username you will have to provide a password. If you have already done that, you know that WordPress does not have an integrated password generator; there is only an indicator which will inform you about the strength of your newly entered password.

You definitely want your WordPress installation to be safe, so you want your users to have strong passwords for their profiles which can’t be easily hacked into. There are many security options you can set up in your WP with various plugins, but let’s start with the simplest one – creating a random password for new users.

With WP Password Generator, you can easily get your generator embedded into WordPress.

So, how do you that:

  1. Navigate to Plugins -> Add New
  2. Find “WP Password Generator
  3. Install and Activate it
  4. Go to Users -> Add New
  5. Under Password textbox, you will a see a new “Generate password” button

This plugin is easy to modify so you don’t have to use the default combination. Let’s say you want to use a password which is 12 character long:

  1. Open functions.php file
  2. Paste the following code
  3. function mysite_set_password_requirements( $args ) {
      $args['length'] = 12;
      return $args;
    }
    add_action( 'wp_password_generator_args', 'mysite_set_password_requirements' );
  4. Save the file and now your password will be 12 characters long

As you can already see from the short snippet above, all you have to do is change the $args[‘length’] = 12; to any number you want.

If you want even more options, see how to force your users to create a strong password when they register themselves.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *