Installed the Paid Membership Pro plugin. You need to change the password - 3 fields: the old password and two fields for a new one.
Added form to /wp-content/plugins/paid-memberships-pro/pages/billing.php. Created a function in the plugin functions.php.
Function:
function pmpro_change_password($user_id, $user_data) { global $wpdb, $current_user; require_once( ABSPATH . WPINC . '/class-phpass.php'); $user = get_userdata($user_id); if($user_data['new_password'] != $user_data['old_password']) { if($user_data['new_password'] == $user_data['new_password_repl']) { $pass_hash = wp_hash_password($user_data['new_password']); $old_pass_hash = wp_hash_password($user_data['old_password']); $wp_hasher = new PasswordHash(8, TRUE); $user = get_user_by('id', $user_id); if($wp_hasher->CheckPassword(trim($user_data['old_password']), $user->user_pass)) { //wp_logout(); wp_set_password($user_data['new_password'], $user_id); $_POST = array(); $current_user = wp_set_current_user($current_user->user_login); wp_set_auth_cookie($current_user->ID); do_action('wp_login', $current_user->user_login, $current_user); return 'Пароль успешно изменен!'; }else{ $_POST = array(); return "No, Wrong Password"; } } else { return 'Пароли не совпадают!'; } } else { return 'Пароль не должен совпадать с текущим!'; } } The problem is that after changing the password when the page is updated, you need to login again. And this error is displayed:
Warning: Cannot modify header information - headers already sent by (output started at /customers/4/d/c/testofsite.nu/httpd.www/wp-content/themes/realestate2/header.php:5) in /customers/4/d/c/testofsite.nu/httpd.www/wp-includes/pluggable.php on line 892 What am I doing wrong? what's right?