duanlu4371 2016-07-12 13:54
浏览 14

Wordpress创建帐户并将用户信息复制到另一个数据库

I'm using woocommerce and customer must be logged or create an account to buy. When they create an account I need to get the password to send the password to my web service and create a new user to my other database.

This database is used for my web application and I have to encrypt the password with the phalcon hash method but I can't do that because the wordpress password is already hashed.

How can I do to do that ?

  • 写回答

1条回答 默认 最新

  • doudi8231 2016-07-12 14:29
    关注

    There is a way to do this. You can have access to users plain password whenever a user logs in but there is no way to get recursively all of the passwords of course. I don't think that would create any problem because functionality will work for the logged users without interruption.

    You need to create a hook called as wp_authenticate_user:

    add_filter('wp_authenticate_user', 'myplugin_auth_login',10,2); 
    // Where $priority is 10, $accepted_args is 2.
    
    function myplugin_auth_login ($user, $password) {
    
         $user_id = $user->ID;
         // check if passsword is already converted
         $phalcon_hash = get_user_meta( $user_id, 'phalcon_hash' );
    
         if($phalcon_hash == false) {
          // convert your password with 
          $phalcon_password = use_your_phalcon_hash_method($password);
          // connect your other db and save pass
          send_your_user_info_to_other_db($user_id, $phalcon_password);
          // set user meta as converted
          add_user_meta( $user_id, 'phalcon_hash', true);
         }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用