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 );