I want to show hidden password fields on registration form. I found that these fields are already present in /wp-admin/user-new.php

<?php if ( apply_filters('show_password_fields', true) ) : ?>
<tr class="form-field form-required">
    <th scope="row"><label for="pass1"><?php _e('Password'); ?> <span class="description"><?php /* translators: password input field */_e('(twice, required)'); ?></span></label></th>
    <td><input name="pass1" type="password" id="pass1" autocomplete="off" />
    <br />
    <input name="pass2" type="password" id="pass2" autocomplete="off" />
    <br />
    <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
    <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
    <th scope="row"><label for="send_password"><?php _e('Send Password?') ?></label></th>
    <td><label for="send_password"><input type="checkbox" name="send_password" id="send_password" <?php checked( $new_user_send_password ); ?> /> <?php _e('Send this password to the new user by email.'); ?></label></td>
 <?php endif; ?>

I assumed that show_password_fields is a function, that returns some value, so I can change its behavior with filters. Then I add following to my functions.php:

add_filter( 'show_password_fields', function(){return true} );

but nothing happend. Is it possible to do it with one or two lines? Thanks in advance!

  • 1
    "I want to show hidden password fields": what do you mean by that? Turn the fields into regular text fields?
    – brasofilo
    Commented Jan 10, 2013 at 9:57

2 Answers 2


show_passwords_fields actually is a filter! You can hook into it as you did above, using an anonymous function:

add_filter( 'show_password_fields', function(){return true} );

You can also write a function, and use it as a callback:

function wpse_79994_show_password_fields() {
    return true;
add_filter( 'show_password_fields', 'wpse_79994_show_password_fields' );

However, as are only returning a boolean (true or false) value, you can do it like so:

add_filter( 'show_password_fields', '__return_true' );

Now, I understand that all of this talk about filters doesn't actually solve your problem. The code you use above should, and does work, eccept you are returning true. As you can see from the apply_filters() function in the first piece of code in your question, true is actually the default value: you aren't actually changing anything!

If you wanted the result of apply_filters('show_password_fields', true ) to be false, you can use this code:

add_filter( 'show_password_fields', '__return_false' );

Edit: The reason that, even with your filter, apply_filters('show_password_fields', true ) is still returning false must be because a filter in one of your plugins is changing it to false after your filter is applied. You can override this by increasing the priority of your filter:

add_filter( 'show_password_fields', '__return_true', 999 );
  • Thank you for fast reply, @bungeshea ! apply_filters actually calls the hook with specified parameters and returns result. I think result of apply_filters('show_password_fields', true) equals false, and this is a reason why password fields now are hidden. In your code must be two underscores '__return_false', and for my regret it also doesn't work. Could you please check if it works with your blog?
    – Pavel K
    Commented Jan 10, 2013 at 9:30
  • You're right about using two underscores. See my updated answer for a possible solution to your issue
    – shea
    Commented Jan 10, 2013 at 9:39

Hi You can user this plugin for add password field in registration https://wordpress.org/plugins/as-password-field-in-default-registration-form/

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.