1

I have this hook created to retrieve user password when he register or update his pass. I dont want my client to touch wordpress core so i was planning to use a hook in wp-includes/user.php All this come from this other post as i cant find any other better solution

MY problem is that the hook is being called but variables are empty.

function encrypt_password_function($pass, $id){
    global $wpdb;
    $encrypted=sha1($pass);
    $wpdb->query($wpdb->prepare("UPDATE wp_users SET iphone_pass = %s WHERE ID = %d",array($encrypted, '10')));
}


function encrypt_password() {
    do_action('encrypt_password');
}
add_action('encrypt_password', 'encrypt_password_function', 1); 
7
  • 1
    How and where are you calling these functions? encrypt_password() without any arguments and with hook inside doesn't make sense.
    – Rarst
    Commented Sep 14, 2011 at 15:38
  • Im calling in wp-includes/user.php inside wp_insert_user function like these: encrypt_password($plain_password, $user_id); I get the plain password var before password get hashed.
    – chifliiiii
    Commented Sep 14, 2011 at 21:22
  • ok now i realized i was doing wrong the add_action. But now the pass is hashed and nto plain like it says on the function description :(
    – chifliiiii
    Commented Sep 14, 2011 at 21:59
  • Are you modifying core file to run this? Just don't. I won't even go there. :)
    – Rarst
    Commented Sep 14, 2011 at 22:00
  • I cant find any other way to get plain password when user register or update his password :(
    – chifliiiii
    Commented Sep 14, 2011 at 22:02

1 Answer 1

1

Ok i can pass variables to hook but i was doing it wrong. Code should be:

function encrypt_password_function($pass, $id){
    global $wpdb;
    $encrypted=sha1($pass);
    $wpdb->query($wpdb->prepare("UPDATE wp_users SET iphone_pass = %s WHERE ID = %d",array($encrypted, '10')));
}


function encrypt_password($var1, $var2) {
    do_action('encrypt_password',$var1, $var2);
}
add_action('encrypt_password', 'encrypt_password_function', 1,2); 

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.