Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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); 
share|improve this question
1  
How and where are you calling these functions? encrypt_password() without any arguments and with hook inside doesn't make sense. –  Rarst Sep 14 '11 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 Sep 14 '11 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 Sep 14 '11 at 21:59
    
Are you modifying core file to run this? Just don't. I won't even go there. :) –  Rarst Sep 14 '11 at 22:00
    
I cant find any other way to get plain password when user register or update his password :( –  chifliiiii Sep 14 '11 at 22:02
show 2 more comments

1 Answer

up vote 1 down vote accepted

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); 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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