本文整理汇总了PHP中SwpmUtils::update_wp_user方法的典型用法代码示例。如果您正苦于以下问题:PHP SwpmUtils::update_wp_user方法的具体用法?PHP SwpmUtils::update_wp_user怎么用?PHP SwpmUtils::update_wp_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SwpmUtils
的用法示例。
在下文中一共展示了SwpmUtils::update_wp_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id)
{
global $wpdb;
$query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl WHERE member_id = %d", $id);
$member = $wpdb->get_row($query, ARRAY_A);
$email_address = $member['email'];
$user_name = $member['user_name'];
unset($member['member_id']);
unset($member['user_name']);
$form = new SwpmForm($member);
if ($form->is_valid()) {
$member = $form->get_sanitized();
$plain_password = isset($member['plain_password']) ? $member['plain_password'] : "";
SwpmUtils::update_wp_user($user_name, $member);
unset($member['plain_password']);
$wpdb->update($wpdb->prefix . "swpm_members_tbl", $member, array('member_id' => $id));
$message = array('succeeded' => true, 'message' => '<p>Member profile updated successfully.</p>');
$error = apply_filters('swpm_admin_edit_custom_fields', array(), $member + array('member_id' => $id));
if (!empty($error)) {
$message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $error);
SwpmTransfer::get_instance()->set('status', $message);
return;
}
SwpmTransfer::get_instance()->set('status', $message);
$send_notification = filter_input(INPUT_POST, 'account_status_change');
if (!empty($send_notification)) {
$settings = SwpmSettings::get_instance();
$from_address = $settings->get_value('email-from');
$headers = 'From: ' . $from_address . "\r\n";
$subject = filter_input(INPUT_POST, 'notificationmailhead');
$body = filter_input(INPUT_POST, 'notificationmailbody');
$settings->set_value('account-change-email-body', $body)->set_value('account-change-email-subject', $subject)->save();
$member['login_link'] = $settings->get_value('login-page-url');
$member['user_name'] = $user_name;
$member['password'] = empty($plain_password) ? SwpmUtils::_("Your current password") : $plain_password;
$values = array_values($member);
$keys = array_map('swpm_enclose_var', array_keys($member));
$body = html_entity_decode(str_replace($keys, $values, $body));
wp_mail($email_address, $subject, $body, $headers);
}
wp_redirect('admin.php?page=simple_wp_membership');
exit(0);
}
$message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors());
SwpmTransfer::get_instance()->set('status', $message);
}
示例2: reset_password
public function reset_password($email)
{
$email = sanitize_email($email);
if (!is_email($email)) {
$message = '<div class="swpm-reset-pw-error">' . SwpmUtils::_("Email address not valid.") . '</div>';
$message = array('succeeded' => false, 'message' => $message);
SwpmTransfer::get_instance()->set('status', $message);
return;
}
global $wpdb;
$query = 'SELECT member_id,user_name,first_name, last_name FROM ' . $wpdb->prefix . 'swpm_members_tbl ' . ' WHERE email = %s';
$user = $wpdb->get_row($wpdb->prepare($query, $email));
if (empty($user)) {
$message = '<div class="swpm-reset-pw-error">' . SwpmUtils::_("No user found with that email address.") . '</div>';
$message .= '<div class="swpm-reset-pw-error-email">' . SwpmUtils::_("Email Address: ") . $email . '</div>';
$message = array('succeeded' => false, 'message' => $message);
SwpmTransfer::get_instance()->set('status', $message);
return;
}
$settings = SwpmSettings::get_instance();
$password = wp_generate_password();
$password_hash = SwpmUtils::encrypt_password(trim($password));
//should use $saned??;
$wpdb->update($wpdb->prefix . "swpm_members_tbl", array('password' => $password_hash), array('member_id' => $user->member_id));
//Update wp user password
add_filter('send_password_change_email', array(&$this, 'dont_send_password_change_email'), 1, 3);
//Stop wordpress from sending a reset password email to admin.
SwpmUtils::update_wp_user($user->user_name, array('plain_password' => $password));
$body = $settings->get_value('reset-mail-body');
$subject = $settings->get_value('reset-mail-subject');
$search = array('{user_name}', '{first_name}', '{last_name}', '{password}');
$replace = array($user->user_name, $user->first_name, $user->last_name, $password);
$body = html_entity_decode($body);
$body = str_replace($search, $replace, $body);
$from = $settings->get_value('email-from');
$headers = "From: " . $from . "\r\n";
wp_mail($email, $subject, $body, $headers);
SwpmLog::log_simple_debug("Member password has been reset. Password reset email sent to: " . $email, true);
$message = '<div class="swpm-reset-pw-success">' . SwpmUtils::_("New password has been sent to your email address.") . '</div>';
$message .= '<div class="swpm-reset-pw-success-email">' . SwpmUtils::_("Email Address: ") . $email . '</div>';
$message = array('succeeded' => false, 'message' => $message);
SwpmTransfer::get_instance()->set('status', $message);
}