function wp_new_user_notification($user_id, $deprecated = null, $notify = '') { $user = get_userdata($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); $user_name = stripslashes($user->display_name); $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $subject = 'Bem-vindo ao ' . $blogname . ', ' . $user_name; // Vamos enviar um email simples ao administrador $message = sprintf(__('New user registration on your site %s:'), $blogname) . "<br><br>"; $message .= sprintf(__('Username: %s'), $user_login) . "<br>"; $message .= sprintf(__('E-mail: %s'), $user_email); @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); $key = get_password_reset_key($user); /* Vamos enviar o email customizado para o usuário. */ if ($user->roles[0] == 'gestor') { $login_url = get_permalink(get_page_by_path('espaco-do-gestor')); } else { $login_url = site_url(); } ob_start(); include 'email_header.php'; ?> <p style="text-transform: uppercase; font-size: 24px; color: #58595B; font-weight: 700; margin-bottom: 15px;"><span style="display: block; font-size: 14px; color: #939598;">Olá</span> <?php echo esc_html($user_name); ?> ,</p> <span style="width: 70px; height: 4px; background-color: #F03F3D; display: block; margin-bottom: 30px;"></span> <p style="font-size: 16px; color: #58595B; font-weight: 100;">Obrigado por se juntar ao <?php echo $blogname; ?> !</p> <p style="font-size: 16px; color: #58595B; font-weight: 100;">O seu nome de usuário é <strong><?php echo esc_html($user_login); ?> </strong> e, para definir sua senha, <a style="margin-top: 10px; padding: 8px 12px; background-color: #F03F3D; color: #fff; border-radius: 4px;" href="<?php echo get_permalink(get_page_by_path('redefinir-senha')) . "?action=rp&key=" . $key . "&login="******">Clique aqui</a> </p> <br><br> <p style="font-size: 16px; color: #58595B; font-weight: 100;">Para fazer seu login, <a href="<?php echo $login_url; ?> ">clique aqui!</a></p> <?php include 'email_footer.php'; $message = ob_get_contents(); ob_end_clean(); wp_mail($user_email, $subject, $message); }
static function init() { Router::routes([self::WEBHOOK_URL => function () { //\Analog::log('Reqest body: '.file_get_contents('php://input'), \Analog::DEBUG); //\Analog::log('Request Hash: '.static::getHash(), \Analog::DEBUG); //\Analog::log('Header Hash: '. ( isset($_SERVER['HTTP_X_SIGNATURE']) ? $_SERVER['HTTP_X_SIGNATURE'] : " ( not found ) " ) , \Analog::DEBUG); if (!static::authenticate()) { //\Analog::log('Webhook failed to authenticate', \Analog::DEBUG); header('HTTP/1.0 401 Unauthorized'); exit; } //\Analog::log('Webhook authenticated.', \Analog::DEBUG); $data = json_decode(static::getRequestBody(), true); $username = $data['user']['id']; $was_user = $data['was_user']; //\Analog::log('User ID: '.$username, \Analog::DEBUG); //\Analog::log('Was User: '******'login', $username))) { //\Analog::log('No user found', \Analog::DEBUG); return false; //No such user } $user_id = $user->ID; if ($was_user === true) { Events::track(['verb' => 'webhook-was-user', 'eventEndpoint' => API::getEventsEndpoint(), 'user' => $user]); } else { if ($was_user === false) { Events::track(['verb' => 'webhook-resetting-password', 'eventEndpoint' => API::getEventsEndpoint(), 'user' => $user]); //Destory sessoins, //\Analog::log('Destroying session', \Analog::DEBUG); $sessions = \WP_Session_Tokens::get_instance($user_id); $sessions->destroy_all(); //Create new password //\Analog::log('Creating new password', \Analog::DEBUG); wp_set_password(wp_generate_password(), $user_id); $key = get_password_reset_key($user); //Email user with Reset password link //\Analog::log('Emailing user with reset password link', \Analog::DEBUG); Email::passwordReset($user, $key); } else { Events::track(['verb' => 'webhook-login-anomaly', 'eventEndpoint' => API::getEventsEndpoint(), 'user' => $user]); } } }]); }
function umc_info_setpass() { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_USER; $uuid = $UMC_USER['uuid']; $user_login = umc_wp_get_login_from_uuid($uuid); // get userdata // this code is copied from wp-login.php, round line 325, grep for 'get_password_reset_key' $user_data = get_user_by('login', $user_login); $reset_key = get_password_reset_key($user_data); $url = network_site_url("wp-login.php?action=rp&key={$reset_key}&login="******"Password Reset Link"); umc_echo("Please click on the following link to set a new password:"); umc_echo($shortenedurl); umc_footer(); }
/** * Handles sending password retrieval email to user. * * @global wpdb $wpdb WordPress database abstraction object. * @global PasswordHash $wp_hasher Portable PHP password hashing framework. * * @return bool|WP_Error True: when finish. WP_Error on error */ function retrieve_password() { global $wpdb, $wp_hasher; $errors = new WP_Error(); if (empty($_POST['user_login'])) { $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or email address.')); } elseif (strpos($_POST['user_login'], '@')) { $user_data = get_user_by('email', trim($_POST['user_login'])); if (empty($user_data)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); } } else { $login = trim($_POST['user_login']); $user_data = get_user_by('login', $login); } /** * Fires before errors are returned from a password reset request. * * @since 2.1.0 * @since 4.4.0 Added the `$errors` parameter. * * @param WP_Error $errors A WP_Error object containing any errors generated * by using invalid credentials. */ do_action('lostpassword_post', $errors); if ($errors->get_error_code()) { return $errors; } if (!$user_data) { $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or email.')); return $errors; } // Redefining user_login ensures we return the right case in the email. $user_login = $user_data->user_login; $user_email = $user_data->user_email; $key = get_password_reset_key($user_data); if (is_wp_error($key)) { return $key; } $message = __('Someone has requested a password reset for the following account:') . "\r\n\r\n"; $message .= network_home_url('/') . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n"; $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; $message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login="******">\r\n"; if (is_multisite()) { $blogname = $GLOBALS['current_site']->site_name; } else { /* * The blogname option is escaped with esc_html on the way into the database * in sanitize_option we want to reverse this for the plain text arena of emails. */ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); } $title = sprintf(__('[%s] Password Reset'), $blogname); /** * Filter the subject of the password reset email. * * @since 2.8.0 * @since 4.4.0 Added the `$user_login` and `$user_data` parameters. * * @param string $title Default email title. * @param string $user_login The username for the user. * @param WP_User $user_data WP_User object. */ $title = apply_filters('retrieve_password_title', $title, $user_login, $user_data); /** * Filter the message body of the password reset mail. * * @since 2.8.0 * @since 4.1.0 Added `$user_login` and `$user_data` parameters. * * @param string $message Default mail message. * @param string $key The activation key. * @param string $user_login The username for the user. * @param WP_User $user_data WP_User object. */ $message = apply_filters('retrieve_password_message', $message, $key, $user_login, $user_data); if ($message && !wp_mail($user_email, wp_specialchars_decode($title), $message)) { wp_die(__('The email could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.')); } return true; }
/** * Handles sending password retrieval email to user. * * @since 6.0 * @access public * @uses $wpdb WordPress Database object * * @return bool|WP_Error True: when finish. WP_Error on error */ public static function retrieve_password() { global $wpdb, $wp_hasher; $errors = new WP_Error(); if (empty($_POST['user_login'])) { $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'theme-my-login')); } else { if (strpos($_POST['user_login'], '@')) { $user_data = get_user_by('email', trim($_POST['user_login'])); if (empty($user_data)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'theme-my-login')); } } else { $login = trim($_POST['user_login']); $user_data = get_user_by('login', $login); } } do_action('lostpassword_post', $errors); if ($errors->get_error_code()) { return $errors; } if (!$user_data) { $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'theme-my-login')); return $errors; } // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; $user_email = $user_data->user_email; $key = get_password_reset_key($user_data); if (is_wp_error($key)) { return $key; } $message = __('Someone requested that the password be reset for the following account:', 'theme-my-login') . "\r\n\r\n"; $message .= network_home_url('/') . "\r\n\r\n"; $message .= sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n\r\n"; $message .= __('If this was a mistake, just ignore this email and nothing will happen.', 'theme-my-login') . "\r\n\r\n"; $message .= __('To reset your password, visit the following address:', 'theme-my-login') . "\r\n\r\n"; $message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login="******">\r\n"; if (is_multisite()) { $blogname = $GLOBALS['current_site']->site_name; } else { // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); } $title = sprintf(__('[%s] Password Reset', 'theme-my-login'), $blogname); $title = apply_filters('retrieve_password_title', $title, $user_login, $user_data); $message = apply_filters('retrieve_password_message', $message, $key, $user_login, $user_data); if ($message && !wp_mail($user_email, $title, $message)) { wp_die(__('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login')); } return true; }
<?php ob_start(); include_once '../../../wp-config.php'; include_once '../../../wp-load.php'; if ($_REQUEST['password_email']) { $password_email = $_REQUEST['password_email']; $user_data = get_user_by('email', trim($password_email)); $user_login = $user_data->user_login; $user_email = $user_data->user_email; $key = get_password_reset_key($user_data); $link = network_site_url("wp-login.php?action=rp&key={$key}&login="******"NashVancouver.com - Восстановление пароля!"; $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; $headers[] = 'Content-Type: text/html; charset=UTF-8' . '\\r\\n'; $headers[] = 'From: NashVancouver.com <*****@*****.**>'; $message = '<html> <head> <title>Спасибо за регистрацию</title> <meta charset="UTF-8"> </head> <body style="margin: 0; padding: 0; font-family: \'Arial\';"> <table style="background: #044b81; width: 100%;"> <tr> <td> <table style="width: 600px; margin: auto;"> <tr> <td style="text-align: center;"><a href="#" style="color: #fff; text-decoration: none; font-size: 12px;">О Ванкувере</a></td> <td style="text-align: center;"><a href="#" style="color: #fff; text-decoration: none; font-size: 12px;">Блоги</a></td> <td style="text-align: center;"><a href="#" style="color: #fff; text-decoration: none; font-size: 12px;">Поддержите проект</a></td> <td style="text-align: center;"><a href="#" style="color: #fff; text-decoration: none; font-size: 12px;">Связь с нами</a></td>
/** * Return the reset link. * * @return string|WP_Error|false If the reset key could not be generated, an error is returned. * @access public * @since 1.4.0 */ public function get_reset_link() { if (!isset($this->reset_link)) { if (!is_a($this->user, 'WP_User')) { charitable_get_deprecated()->doing_it_wrong(__METHOD__, __('Password reset link cannot be generated without a WP_User object.', 'charitable'), '1.4.0'); return ''; } $base_url = charitable_get_permalink('reset_password_page'); $key = get_password_reset_key($this->user); if (is_wp_error($key)) { return $key; } $this->reset_link = esc_url_raw(add_query_arg(array('key' => $key, 'login' => rawurlencode($this->user->user_login)), $base_url)); } return $this->reset_link; }
/** * Handles sending password retrieval email to customer. * * Based on retrieve_password() in core wp-login.php. * * @uses $wpdb WordPress Database object * @return bool True: when finish. False: on error */ public static function retrieve_password() { global $wpdb, $wp_hasher; $login = trim($_POST['user_login']); if (empty($login)) { wc_add_notice(__('Enter a username or e-mail address.', 'woocommerce'), 'error'); return false; } else { // Check on username first, as customers can use emails as usernames. $user_data = get_user_by('login', $login); } // If no user found, check if it login is email and lookup user based on email. if (!$user_data && is_email($login) && apply_filters('woocommerce_get_username_from_email', true)) { $user_data = get_user_by('email', $login); } do_action('lostpassword_post'); if (!$user_data) { wc_add_notice(__('Invalid username or e-mail.', 'woocommerce'), 'error'); return false; } if (is_multisite() && !is_user_member_of_blog($user_data->ID, get_current_blog_id())) { wc_add_notice(__('Invalid username or e-mail.', 'woocommerce'), 'error'); return false; } // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; do_action('retrieve_password', $user_login); $allow = apply_filters('allow_password_reset', true, $user_data->ID); if (!$allow) { wc_add_notice(__('Password reset is not allowed for this user', 'woocommerce'), 'error'); return false; } elseif (is_wp_error($allow)) { wc_add_notice($allow->get_error_message(), 'error'); return false; } // Get password reset key (function introduced in WordPress 4.4). $key = get_password_reset_key($user_data); // Send email notification WC()->mailer(); // load email classes do_action('woocommerce_reset_password_notification', $user_login, $key); return true; }
/** * Notify the blog admin of a new user, normally via email. * * @since 2.0 */ function em_new_user_notification() { global $em_temp_user_data; $user_id = $em_temp_user_data['user_id']; $plaintext_pass = $em_temp_user_data['user_pass']; //if you want you can disable this email from going out, and will still consider registration as successful. if (get_option('dbem_email_disable_registration')) { return true; } //Copied out of /wp-includes/pluggable.php $user = new WP_User($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New user registration on your blog %s:', 'events-manager'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s', 'events-manager'), $user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s', 'events-manager'), $user_email) . "\r\n"; @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration', 'events-manager'), $blogname), $message); if (empty($plaintext_pass)) { return; } //send email to user $message = get_option('dbem_bookings_email_registration_body'); if (em_locate_template('emails/new-user.php')) { ob_start(); em_locate_template('emails/new-user.php', true); $message = ob_get_clean(); } //for WP 4.4, regenerate password link can be used $set_password_url = ''; if (function_exists('get_password_reset_key')) { $key = get_password_reset_key($user); $set_password_url = network_site_url("wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user_login), 'login'); } $message = str_replace(array('%password%', '%username%', '%passwordurl%'), array($plaintext_pass, $user_login, $set_password_url), $message); global $EM_Mailer; return $EM_Mailer->send(get_option('dbem_bookings_email_registration_subject'), $message, $user_email); }
function hocwp_execute_lostpassword() { $http_post = 'POST' == $_SERVER['REQUEST_METHOD']; $user = null; $user_login = ''; $user_id = ''; $user_email = ''; $error = false; $message = __('There was an error occurred, please try again.', 'hocwp-theme'); $redirect = hocwp_get_value_by_key($_REQUEST, 'redirect_to'); $redirect_to = apply_filters('lostpassword_redirect', $redirect); if (is_user_logged_in()) { if (empty($redirect_to)) { $redirect_to = home_url('/'); } wp_redirect($redirect_to); exit; } $transient = ''; $captcha = hocwp_get_method_value('captcha'); if ($http_post) { $action = hocwp_get_method_value('action'); if ('lostpassword' === $action || 'retrievepassword' === $action) { $user_login = hocwp_get_method_value('user_login'); $transient_name = hocwp_build_transient_name('hocwp_lostpassword_user_%s', $user_login); if ((isset($_POST['submit']) || isset($_POST['wp-submit'])) && false === ($transient = get_transient($transient_name))) { if (empty($user_login)) { $error = true; $message = __('Please enter your account name or email address.', 'hocwp-theme'); } else { if (isset($_POST['captcha'])) { $capt = new HOCWP_Captcha(); if (!$capt->check($captcha)) { $error = true; $message = __('The security code is incorrect.', 'hocwp-theme'); } } if (!$error) { $user = hocwp_return_user($user_login); if (!is_a($user, 'WP_User')) { $error = true; $message = __('Username or email is not exists.', 'hocwp-theme'); } else { $user_login = $user->user_login; $user_id = $user->ID; $user_email = $user->user_email; } } } if (!$error && is_a($user, 'WP_User')) { $key = get_password_reset_key($user); if (is_wp_error($key)) { $error = true; $message = __('There was an error occurred, please try again or contact the administrator.', 'hocwp-theme'); } else { $message = wpautop(__('Someone has requested a password reset for the following account:', 'hocwp-theme')); $message .= wpautop(network_home_url('/')); $message .= wpautop(sprintf(__('Username: %s', 'hocwp-theme'), $user_login)); $message .= wpautop(__('If this was a mistake, just ignore this email and nothing will happen.', 'hocwp-theme')); $message .= wpautop(__('To reset your password, visit the following address:', 'hocwp-theme')); $message .= wpautop(network_site_url("wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user_login), 'login')); if (is_multisite()) { $blogname = $GLOBALS['current_site']->site_name; } else { $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); } $title = sprintf(__('[%s] Password Reset'), $blogname); $title = apply_filters('retrieve_password_title', $title, $user_login, $user); $message = apply_filters('retrieve_password_message', $message, $key, $user_login, $user); if (!is_email($user_email)) { $user_email = $user->user_email; } if ($message && !hocwp_send_html_mail($user_email, wp_specialchars_decode($title), $message)) { $error = true; $message = __('The email could not be sent. Possible reason: your host may have disabled the mail() function.', 'hocwp-theme'); } else { $error = false; $message = __('Password recovery information has been sent, please check your mailbox.', 'hocwp-theme'); set_transient($transient_name, $user_id, 15 * MINUTE_IN_SECONDS); } } } } else { if (hocwp_id_number_valid($transient)) { $error = false; $message = __('Password recovery information has been sent, please check your mailbox.', 'hocwp-theme'); } } } } $result = array('user_id' => $user_id, 'user_email' => $user_email, 'user_login' => $user_login, 'captcha' => $captcha, 'error' => $error, 'message' => $message, 'redirect_to' => $redirect_to, 'transient' => $transient); return $result; }