How to get the password and username of the add new user form (admin back end) in wordpress

I am trying to get the username and password that entered by the wordpress admin in the add new user screen to use those into creating a webmail account using cpanel api.

How to do that? is there is any hook for it?

Read More

Also, When the user id changing his password, I want to get the new and old password and use it to change the one for the webmail account.

  • I am not looking for the cpanel part, just the wordpress part.

Related posts

Leave a Reply

1 comment

  1. You’ll need three hooks:

    1: user_register

    This is for when the user is created via the admin back-end. The username will be available via $_POST['user_login'] and the password will be available via $_POST['pass1'].

    2: edit_user_profile_update

    This is for when the password is updated on the profile page by the user or admin. The username will be available via $_POST['user_login'] and the password will be available via $_POST['pass1'].

    3: password_reset

    This is for when the user resets their password using the forgot password page. The username will be available via the first argument $user using $user->user_login. The password will be available via the second argument $new_pass.

    In terms of getting the old password, I don’t think you can. The password is hashed and stored in the database. You have access to the hash, but you can’t reconstruct the old password from it.

    The only option you have there is to store the password somewhere else in an encrypted way so you can retrieve it later and decrypt it, however this method is not recommended from a security point of view.

    I’d recommend finding a way to update the password in cPanel without having the old password.