admin管理员组

文章数量:1415137

I'm trying to add a password form to the WP registration form. See the code below. I was wondering if I need to sanitize this specific user input? (and if so how?)

If I understand it correctly, WP has sanitizion built in for some things, and passwords may be one of them. Is that correct? Will WP sanitize it automatically before adding it to the database?

add_action( 'register_new_user', 'registration_change_pass', 10, 99 );

function registration_change_pass( $user_id ) {

    if ( isset( $_POST['user_password'] ) ) {
        wp_set_password( $_POST['user_password'], $user_id ); }
}

I'm trying to add a password form to the WP registration form. See the code below. I was wondering if I need to sanitize this specific user input? (and if so how?)

If I understand it correctly, WP has sanitizion built in for some things, and passwords may be one of them. Is that correct? Will WP sanitize it automatically before adding it to the database?

add_action( 'register_new_user', 'registration_change_pass', 10, 99 );

function registration_change_pass( $user_id ) {

    if ( isset( $_POST['user_password'] ) ) {
        wp_set_password( $_POST['user_password'], $user_id ); }
}
Share Improve this question edited Aug 26, 2019 at 3:28 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Aug 25, 2019 at 17:56 J. StocklandJ. Stockland 1156 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

No, there is no need to sanitize passwords. You don't want to strip out or rewrite a value on users' set passwords. They will be hashed afterwards, so no need

本文标签: phpIs it necessary to sanitize wpsetpassword user input