Auto-Fill password fields when creating new user
-
Hi everyone,
I am trying to achieve that on load of user-new.php the password is created randomly and gets prefilled. To achieve that I have the following code inside my custom admin plugin:
global $pagenow; if ($pagenow == "user-new.php") { wp_enqueue_script('modify-new-user-create-form-js', plugins_url('/js/role-cca_modify_new_user_create_form.js', __FILE__)); }
The js is loaded properly and inside it I have the following lines:
jQuery(document).ready(function($) { var $passwordField1 = $('#pass1'); var $passwordField2 = $('#pass2'); var randomPW = Math.random().toString(36).slice(-8); $passwordField1.$passwordField2.val(randomPW); });
Sadly the fields are not filled with the vaule. If I assign the value to a non-password input field it works. So seems to me that wordpress core is denying an automated password insert via javascript for security reasons!? Is that guess right and is there a way to achieve what I want?
Thanks in advance.
Cheers, Kool
- The topic ‘Auto-Fill password fields when creating new user’ is closed to new replies.