我试图在密码重置后使用$\\u POST方法提交操作下面是代码
add_action( \'after_password_reset\', \'action_function\', 10, 2 );
function action_function( $user, $new_pass ){
if (isset( $_POST[\'password_1\'] ) ) {
update_user_meta($user->ID, \'user_pass2\', password_hash($_POST[\'password_1\'], PASSWORD_DEFAULT));
}
}
但它不会被解雇有小费吗?
还有reason 我需要另一个应用程序凭据使用的密码。例如,以下代码显示了我在profile\\u更新期间如何使用$\\u POST
function my_profile_update( $user_id ) {
// password changed...
if ( ! is_admin() && isset( $_POST[\'password_1\'] ) ) {
update_user_meta($user_id, \'user_pass2\', password_hash($_POST[\'password_1\'], PASSWORD_DEFAULT));
global $wpdb;
global $current_user;
$script_db = new wpdb(\'db\', \'pass\', \'user\', \'localhost\');
get_currentuserinfo();
$email = (string) $current_user->user_email;
$password = (string) get_user_meta( $current_user->ID, \'user_pass2\', true );;
$query = $script_db->prepare( "SELECT * FROM {$script_db->prefix}np_users WHERE email = %s", $email );
$results = $script_db->get_results($query);
if(count( $results ) > 0) {
$id = $results[0]->id;
$script_db->update(\'np_users\', array(
\'password\' => $password
),array(\'id\'=>$id));
}
}
}
add_action( \'profile_update\', \'my_profile_update\' );