在Wordpress中更改密码/重置密码后,将新密码发送到新数据库

时间:2015-08-27 16:53:53

标签: php wordpress-plugin wordpress-theming wordpress

我有两个脚本一起工作,我需要保持用户信息的同步。我对用户名没有任何问题,但是对于密码,我尝试了2个钩子,'password_reset'和'check_passwords',但它没有完成:

add_action( 'password_reset', 'change_password_in_other_script', 10, 2 );
add_action( 'check_passwords', 'change_password_in_other_script', 10, 2 );
function change_password_in_other_script( $user, $new_pass ) {

    // OTHER DB CREDENTIALS
    global $addShareDB; 
    // INITIALIZE OTHER DB CONNECTION   
    $mydb = new wpdb( $addShareDB['dbuser'], $addShareDB['dbpass'], $addShareDB['dbname'], $addShareDB['dbhost'] );

    $current_user = wp_get_current_user();
    $current_username = $current_user->user_login;

    $table           = 'enk_account_users';
    $new_password    = md5( $_POST[ 'pwd' ] );
    $query = "UPDATE " . $table . " SET password = '" . $new_password . "' WHERE username = '" . $current_username . "'";
    $mydb->get_results( $query );
}

我可以使用其他钩子吗?

我想要做的是能够在密码重置或更改后插入wordpress数据库后立即处理新创建的纯文本密码。所以我也可以将它更新到另一个框架的数据库中,或者甚至可以将它发布到另一个框架中的脚本中。

谢谢

1 个答案:

答案 0 :(得分:3)

是的,您可以使用profile_update挂钩来更新密码。

在主题functions.php文件中,放入配置文件更新挂钩。

您可以检查以下代码以获取更多参考。

Dim path As String
Dim fn1 As String
Dim fn2 As Date
Dim fn3 As String

path = "C:\Users\Christine Cordero\Desktop\Evercrete Philippines Transactions\Clients\Transaction Invoices"
fn1 = Range("CustomerNameLine").Value
fn2 = Range("InvoiceNumberDate").Value
fn3 = Range("InvoiceNumberLine").Value

Application.DisplayAlerts = False

'this is one code I was trying to save only a range of that sheet.   

' Save Invoice as PDF Option 1
Range("Print_Area").SaveAs filename:=path & fn1 & " " & fn2 & " " & fn3 & " " & ".xlsx", FileFormat:=xlOpenDocumentSpreadsheet
相关问题