简体   繁体   English

如何解密存储在drupal到wordpress数据库中的密码?

[英]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. 我忘记了drupal中的密码表单,一旦用户单击“保存”按钮需要将更改的密码保存在wordpress数据库用户表中。 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. 不确定您可以直接从hook_form_alter()中读取提交的值。 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. 然后创建另一个称为该函数的函数(“ my_custom_submit_handler()”),因此当表单提交者时,还将调用您的自定义提交表单处理程序,您可以收集密码数据并保存它。

https://www.drupal.org/forum/support/module-development-and-code-questions/2010-01-29/adding-custom-submit-handlers-to-a 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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