I'm trying to get the encrypted user_pass
data from my wp_users
table in my database to show up as a custom editable and updatable field (like the email field) in the "Edit User" pages within the admin side only. I have come up with the following code:
if ( is_admin() ) {
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) { ?>
<h3>Additional Account Information</h3>
<table class="form-table">
<tbody>
<tr>
<th style="width:20.5%!important;">Existing Password (Encrypted)</th>
<td>
<input type="text" name="user_pass" id="user_pass" value="<?php echo esc_attr($user->user_pass) ?>" class="regular-text" />
</td>
</tr>
</tbody>
</table>
<?php }
add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
$user_id = wp_update_user( array( 'ID' => $user_id, 'user_pass' => $_POST[ 'user_pass' ] ) );
}
}
UPDATE:
The code above is working but when it updates it is re-encrypting the already encrypted password I am copy and pasting. Thereby making the encrypted password the password itself! I just want it to save the exact way I paste it in. Is this even possible?
I want this data so I am able to copy and paste it from one user area to another within my site as they do not share databases, however some users need to be in more than one database with the same information including password. I would like to be able to do that right from the Wordpress Admin areas instead of in phpMyAdmin.