简体   繁体   中英

How to decrypt the password stored in drupal to wordpress database?

I am having forgot password form which is in drupal once user click the save button need to save the changed password in wordpress database user table. how to achieve it?

function wp_login_form_alter(&$form, &$form_state, $form_id) {
//echo "hi";

    if($form_id=="user_profile_form"){

        print '<pre>';
        //print_r($form);
        print_r($form_state['user']);
        echo $form_state['user']->uid;
        echo $form_state['user']->name;
        echo $form_state['user']->mail;
        echo $form_state['user']->pass;
        echo $form_state['user']->login;
        exit;
        //UPDATE wp_users SET user_pass = md5($new_password) WHERE ID = $user_id


    }
}

Not sure that you can read submitted values from hook_form_alter() directly. Instead I think that you should add (register) your custom submission form handler from there:

$form['#submit'][] = 'my_custom_submit_handler';

And then make another function called that way ("my_custom_submit_handler()"), so when form is submitter your custom submission form handler will be also called and you can collect password data and save it.

https://www.drupal.org/forum/support/module-development-and-code-questions/2010-01-29/adding-custom-submit-handlers-to-a

What you can do is:

Setting the password to a random value, using user_hash_password()
Show a message to the users telling them they need to reset their password
The right way to call user_hash_password() is the following one.

require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
$hash = user_hash_password($password);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM