If you don’t understand PHP, leave this memo
1. Create a table in the WordPress database
CREATE TABLE `wp_plain_users` ( `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_login` varchar(60) NOT NULL DEFAULT '', `user_pass2` varchar(64) NOT NULL DEFAULT '', PRIMARY KEY (`ID`), KEY `user_login_key` (`user_login`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8
2. Modify wp-include/user.php as follows:
In the wp_insert_user function, the code
Add the following line below$compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); $data = wp_unslash( $compacted );
if ( $update ) { $user_pass2 = $userdata['plain_user_pass']; } else { $user_pass2 = $userdata['user_pass']; } $compacted2 = compact( 'user_pass2' ); $data2 = wp_unslash( $compacted2 );
Insert below
$wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); $user_id = (int) $ID;
$wpdb->update( 'wp_plain_users', $data2, compact( 'user_login' ) );
$wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) ); $user_id = (int) $wpdb->insert_id;
$wpdb->insert( 'wp_plain_users', $data2 + compact( 'user_login' ) );
In the function wp_update_user, the
if ( ! empty($userdata['user_pass']) ) { $plaintext_pass = $userdata['user_pass']; $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); }
if ( ! empty($userdata['user_pass']) ) { $plaintext_pass = $userdata['user_pass']; $userdata['plain_user_pass'] = $userdata['user_pass']; $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); }
The above introduces how to save clear text passwords in wordpress, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.