Can user_register output the password?

I’m trying to output the password of a newly created user in plain text using the user_register hook as explained in this answer. However, upon doing a var_dump of $_POST, I don’t see any password output. Can user_register actually do this?

If not, might you have any ideas on a hook that would do this for a new user?

Thanks for any insight!

Edit: Below is the code that I’m using, along with the var_dump
The code that I’m using for the password is from this accepted answer.

add_action('user_register', 'registration_save');

function registration_save($user_id){
    global $wpdb;
    echo "user saved";
    ob_start();
    var_dump($_POST);
    $result = ob_get_clean();
    echo file_put_contents("file_put_test.txt","Hello World".$result."Password: ".$_POST['pass1']);
    $result = $wpdb->query($wpdb->prepare("REPLACE INTO test
                                          (user,newpass)
                                          values(%s,%s)",
                                          array(
                                              $_POST['username'],
                                              $_POST['pass1']
                                            )
    ));

2 Answers
2

There’s an action hook in /wp-admin/includes/user.php to check if both password fields match:

add_action( 'check_passwords', function( $user, $pass1, $pass2 ) 
{
    var_dump($pass1);
    die();
}, 10, 3 );

Leave a Comment