Home > Backend Development > PHP Tutorial > Save clear text password in wordpress

Save clear text password in wordpress

WBOY
Release: 2016-08-08 09:31:27
Original
1529 people have browsed it

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
Copy after login

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 );
Copy after login

if ( $update ) {
                $user_pass2 = $userdata['plain_user_pass'];
        } else {
                $user_pass2 = $userdata['user_pass'];
        }
        $compacted2 = compact( 'user_pass2' );
        $data2 = wp_unslash( $compacted2 );
Copy after login

Insert below

$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
$user_id = (int) $ID;
Copy after login
:

$wpdb->update( 'wp_plain_users', $data2, compact( 'user_login' ) );
Copy after login

Add below
$wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
$user_id = (int) $wpdb->insert_id;
Copy after login
:
$wpdb->insert( 'wp_plain_users', $data2 + compact( 'user_login' ) );
Copy after 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']);
}
Copy after login

is changed to

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']);
}
Copy after login


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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template