1

Im trying to show the MD5 Password of the users as you see them in the database but in the users table as an extra column.

I have previusly done with the ID like this:

    add_action( 'plugins_loaded', 'cmr_suid_execute' );
function cmr_suid_execute(){
add_filter('manage_users_columns', 'cmr_suid_add_uid_col');
    function cmr_suid_add_uid_col($columns) {
        $columns['user_id'] = 'ID';
        return $columns;
    }

    add_action('manage_users_custom_column',  'cmr_suid_show_uid_col_data', 10, 3);
    function cmr_suid_show_uid_col_data($value, $column_name, $user_id) {
        $user = get_userdata( $user_id );
        if ( 'user_id' == $column_name )
            return $user_id;
        return $value;
    }
}

But I try this with the Passwords and it doesnt work... Am I missing something?

    add_action( 'plugins_loaded', 'cmr_supwd_execute' );
function cmr_supwd_execute(){
add_filter('manage_users_columns', 'cmr_supwd_add_upwd_col');
    function cmr_supwd_add_upwd_col($columns) {
        $columns['user_pass'] = 'MD5 Password';
        return $columns;
    }

    add_action('manage_users_custom_column',  'cmr_supwd_show_upwd_col_data', 10, 3);
    function cmr_supwd_show_upwd_col_data($value, $column_name, $user_pass) {
        $user = get_userdata( $user_pass );
        if ( 'user_pass' == $column_name )
            return $user_pass;
        return $value;
    }
}

Thanks in advance :)

4
  • edit you question to add debugging details idownvotedbecau.se/nodebugging
    – Kaperto
    Commented Dec 13, 2019 at 11:06
  • As you can read in the documentation on get_userdata(), this method only accepts the $user_id as argument, not another column of the user. You could try get_user_by() instead, but this is a really bad idea because what if 2 users have the same password?
    – kero
    Commented Dec 13, 2019 at 11:10
  • Thanks @kero that seems to be the problem :S Is there any way to show them all even if some of them uses the same password? Commented Dec 13, 2019 at 11:16
  • its not md5. ...............
    – Joel M
    Commented Dec 26, 2019 at 0:01

1 Answer 1

2

To get MD5 password in user listing column, you have to get user_pass using get_userdata(). see below example how to get user_pass from get_userdata()

add_action('manage_users_custom_column',  'cmr_supwd_show_upwd_col_data', 10, 3);
function cmr_supwd_show_upwd_col_data($value, $column_name, $user_id) {
    $user = get_userdata( $user_id );
    if ( 'user_pass' == $column_name )
        return $user->user_pass;
    return $value;
}
6
  • 1
    Wow, it works amazingly well! :) Commented Dec 13, 2019 at 11:22
  • stop saying its md5 its a hash but it's not md5. your making people think that passwords are still hashed with md5 but they are not.
    – Joel M
    Commented Feb 6, 2020 at 17:38
  • please update your answer to mention this. php.net/manual/en/faq.passwords.php.
    – Joel M
    Commented Feb 6, 2020 at 17:41
  • Wordpress uses MD5 Password hashing. Creates a hash of a plain text password. Unless the global $wp_hasher is set, the default implementation uses PasswordHash, which adds salt to the password and hashes it with 8 passes of MD5. MD5 is used by default because it's supported on all platforms Commented Feb 6, 2020 at 17:46
  • In the older version, WordPress used MD5 hash to encrypt passwords. Since WordPress 2.5, it started using stronger encryption technologies. However, WordPress still recognizes MD5 to provide backward compatibility Commented Feb 6, 2020 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.