本文整理汇总了PHP中wp_check_password函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_check_password函数的具体用法?PHP wp_check_password怎么用?PHP wp_check_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_check_password函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
/**
* Generates token.
*
* Uses 'create_token' to create a token.
*
* @since 4.3.0
*
* @param string $request The rest-api request that contains all parameters.
* @return array The token and expiration-timestamp
*/
function action(WP_REST_Request $request)
{
$return = new WP_Error('400', __('Authentication failed.', 'wp_jwt_auth'));
if (isset($request['method'])) {
// if user wants to login by social-media-account
$return = apply_filters('wak_login_method_' . $request['method'], $return, $request);
} else {
// if user wants to login by username/password
$username = $request['username'];
$password = $request['password'];
$jwt_functions = new WAK_Functions();
$user = get_user_by('login', $username);
if ($user && wp_check_password($password, $user->data->user_pass, $user->ID)) {
$return = $jwt_functions->create_token($user->ID);
} else {
$return = new WP_Error('credentials_invalid', __('Username/Password combination is invalid', 'wp_jwt_auth'));
}
}
if (isset($request['set_wp_cookie']) && $request['set_wp_cookie'] == 'true' && !is_wp_error($return)) {
wp_set_auth_cookie($return['userid'], true);
}
if (isset($request['redirect_to']) && !is_wp_error($return)) {
$location = $request['redirect_to'];
if (is_wp_error($return)) {
$location .= '?error=true&msg=' . urlencode($return->get_error_message());
}
wp_redirect($location);
exit;
return;
}
return $return;
}
示例2: process_withdrawal
public static function process_withdrawal()
{
$action = wskl_POST('action');
if ($action != 'dabory_members_withdrawal') {
return;
}
self::evaluate_and_redirect_if_failed(is_user_logged_in(), __('먼저 로그인 하세요', 'wskl'));
self::evaluate_and_redirect_if_failed(wp_verify_nonce($_POST['dabory_members_withdrawal'], 'dabory_members_withdrawal'), __('Nonce 인증에 실패했습니다.', 'wskl'));
$user = wp_get_current_user();
$password = wskl_POST('password');
$reason = wskl_POST('reason', 'sanitize_text_field');
self::evaluate_and_redirect_if_failed(wp_check_password($password, $user->user_pass, $user->ID), __('비밀번호가 일치하지 않습니다.', 'wskl'));
if (wskl_is_option_enabled('members_delete_after_withdrawal')) {
if (!function_exists('wp_delete_user')) {
include_once ABSPATH . 'wp-admin/includes/user.php';
}
// 멤버 정말로 삭제
wp_logout();
wp_delete_user($user->ID);
} else {
// 역할을 바꿔 탈퇴 회원으로 간주
update_user_meta($user->ID, 'withdrawal_reason', $reason);
$user->set_role('wskl_withdrawn');
wp_logout();
}
// 탈퇴 완료 메시지
wp_redirect(add_query_arg(array('status' => 'complete'), $_SERVER['REQUEST_URI']));
exit;
}
开发者ID:EricKim65,项目名称:woosym-korean-localization,代码行数:29,代码来源:class-wskl-dabory-members-withdrawal.php
示例3: wp_check_bind_user
function wp_check_bind_user($username, $password)
{
if (empty($password)) {
return __('<strong>ERROR</strong>: The password field is empty.');
}
$userdata = get_userdatabylogin($username);
if (!$userdata) {
return sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login'));
}
if (is_multisite()) {
// Is user marked as spam?
if (1 == $userdata->spam) {
return __('<strong>ERROR</strong>: Your account has been marked as a spammer.');
}
// Is a user's blog marked as spam?
if (!is_super_admin($userdata->ID) && isset($userdata->primary_blog)) {
$details = get_blog_details($userdata->primary_blog);
if (is_object($details) && $details->spam == 1) {
return __('Site Suspended.');
}
}
}
$userdata = apply_filters('wp_authenticate_user', $userdata, $password);
if (is_wp_error($userdata)) {
return;
}
if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
return sprintf(__('<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?'), $username, site_url('wp-login.php?action=lostpassword', 'login'));
}
}
示例4: um_submit_form_errors_hook_login
function um_submit_form_errors_hook_login($args)
{
global $ultimatemember;
$is_email = false;
$form_id = $args['form_id'];
$mode = $args['mode'];
if (isset($args['username']) && $args['username'] == '') {
$ultimatemember->form->add_error('username', __('Please enter your username or email', 'ultimatemember'));
}
if (isset($args['user_login']) && $args['user_login'] == '') {
$ultimatemember->form->add_error('user_login', __('Please enter your username', 'ultimatemember'));
}
if (isset($args['user_email']) && $args['user_email'] == '') {
$ultimatemember->form->add_error('user_email', __('Please enter your email', 'ultimatemember'));
}
if (isset($args['username'])) {
$field = 'username';
if (is_email($args['username'])) {
$is_email = true;
$data = get_user_by('email', $args['username']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$user_name = $args['username'];
}
} else {
if (isset($args['user_email'])) {
$field = 'user_email';
$is_email = true;
$data = get_user_by('email', $args['user_email']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$field = 'user_login';
$user_name = $args['user_login'];
}
}
if (!username_exists($user_name)) {
if ($is_email) {
$ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that email address', 'ultimatemember'));
} else {
$ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that username', 'ultimatemember'));
}
} else {
if ($args['user_password'] == '') {
$ultimatemember->form->add_error('user_password', __('Please enter your password', 'ultimatemember'));
}
}
$user = get_user_by('login', $user_name);
if ($user && wp_check_password($args['user_password'], $user->data->user_pass, $user->ID)) {
$ultimatemember->login->auth_id = username_exists($user_name);
} else {
$ultimatemember->form->add_error('user_password', __('Password is incorrect. Please try again.', 'ultimatemember'));
}
// add a way for other plugins like wp limit login
// to limit the login attempts
$user = apply_filters('authenticate', null, $user_name, $args['user_password']);
// if there is an error notify wp
if ($ultimatemember->form->has_error($field) || $ultimatemember->form->has_error($user_password)) {
do_action('wp_login_failed', $user_name);
}
}
示例5: updateProfileInformation
static function updateProfileInformation($data)
{
global $_js_helper;
$success = 0;
if (!$_js_helper->is_logged()) {
return false;
}
$args = wp_parse_args($data, array());
if ($args['edit_task'] && $args['edit_task'] == 'change_password') {
$current_user = JS_Helper::get_current_js_user();
if (!wp_check_password($args['old_pass'], $current_user->user_pass, $current_user->ID)) {
return -2;
}
}
$meta_data = $args['meta'];
unset($args['meta']);
if (!is_wp_error(wp_update_user($args))) {
$success++;
}
if ($meta_data) {
foreach ($meta_data as $meta_key => $meta_value) {
$success += update_user_meta($args['ID'], $meta_key, $meta_value) ? 1 : 0;
}
}
return strval($success);
}
示例6: check_custom_authentication
function check_custom_authentication($username, $password)
{
global $wpdb;
$setting_value = array();
$date_time = date("Y-m-d H:i:s");
$ip_Address = getIpAddress();
$log_data = cpo_get_ip_location($ip_Address);
$insert = new log_data();
$setting_value["username"] = isset($_REQUEST["log"]) ? esc_attr($_REQUEST["log"]) : esc_attr($_REQUEST["username"]);
$setting_value["ip_address"] = $ip_Address;
if ($log_data->city == "" || $log_data->country_name == "") {
$setting_value["geo_location"] = $log_data->city . $log_data->country_name;
} else {
$setting_value["geo_location"] = $log_data->city . ", " . $log_data->country_name;
}
$userdata = get_user_by("login", $username);
if (wp_check_password($password, $userdata->user_pass)) {
$setting_value["login_status"] = 1;
} else {
$setting_value["login_status"] = 0;
}
$setting_value["latitude"] = $log_data->latitude;
$setting_value["longitude"] = $log_data->longitude;
$setting_value["date_time"] = $date_time;
$insert->insert_data(cleanup_optimizer_log(), $setting_value);
}
示例7: authenticate
/**
* Filter the user to authenticate.
*
* @since 0.1-dev
*
* @access public
* @static
*
* @param WP_User $input_user User to authenticate.
* @param string $username User login.
* @param string $password User password.
*/
public static function authenticate($input_user, $username, $password)
{
$api_request = defined('XMLRPC_REQUEST') && XMLRPC_REQUEST;
if (!apply_filters('application_password_is_api_request', $api_request)) {
return $input_user;
}
$user = get_user_by('login', $username);
// If the login name is invalid, short circuit.
if (!$user) {
return $input_user;
}
/*
* Strip out anything non-alphanumeric. This is so passwords can be used with
* or without spaces to indicate the groupings for readability.
*/
$password = preg_replace('/[^a-z\\d]/i', '', $password);
$hashed_passwords = get_user_meta($user->ID, self::USERMETA_KEY_APPLICATION_PASSWORDS, true);
foreach ($hashed_passwords as $key => $item) {
if (wp_check_password($password, $item['password'], $user->ID)) {
$item['last_used'] = time();
$item['last_ip'] = $_SERVER['REMOTE_ADDR'];
$hashed_passwords[$key] = $item;
update_user_meta($user->ID, self::USERMETA_KEY_APPLICATION_PASSWORDS, $hashed_passwords);
return $user;
}
}
// By default, return what we've been passed.
return $input_user;
}
示例8: kbs_process_login_form
/**
* Process Login Form
*
* @since 1.0
* @param arr $data Data sent from the login form
* @return void
*/
function kbs_process_login_form($data)
{
if (wp_verify_nonce($data['kbs_login_nonce'], 'kbs-login-nonce')) {
$user_data = get_user_by('login', $data['kbs_user_login']);
if (!$user_data) {
$user_data = get_user_by('email', $data['kbs_user_login']);
}
if ($user_data) {
$user_ID = $user_data->ID;
$user_email = $user_data->user_email;
if (wp_check_password($data['kbs_user_pass'], $user_data->user_pass, $user_data->ID)) {
kbs_log_user_in($user_data->ID, $data['kbs_user_login'], $data['kbs_user_pass']);
} else {
$message = 'password_incorrect';
}
} else {
$message = 'username_incorrect';
}
if (!empty($message)) {
$url = remove_query_arg('message');
wp_redirect(add_query_arg('message', $message, $url));
die;
}
$redirect = apply_filters('kbs_login_redirect', $data['kbs_redirect'], $user_ID);
wp_redirect($redirect);
die;
}
}
示例9: edd_process_login_form
/**
* Process Login Form
*
* @since 1.0
* @param array $data Data sent from the login form
* @return void
*/
function edd_process_login_form($data)
{
if (wp_verify_nonce($data['edd_login_nonce'], 'edd-login-nonce')) {
$user_data = get_user_by('login', $data['edd_user_login']);
if (!$user_data) {
$user_data = get_user_by('email', $data['edd_user_login']);
}
if ($user_data) {
$user_ID = $user_data->ID;
$user_email = $user_data->user_email;
if (wp_check_password($data['edd_user_pass'], $user_data->user_pass, $user_data->ID)) {
edd_log_user_in($user_data->ID, $data['edd_user_login'], $data['edd_user_pass']);
} else {
edd_set_error('password_incorrect', __('The password you entered is incorrect', 'edd'));
}
} else {
edd_set_error('username_incorrect', __('The username you entered does not exist', 'edd'));
}
// Check for errors and redirect if none present
$errors = edd_get_errors();
if (!$errors) {
$redirect = apply_filters('edd_login_redirect', $data['edd_redirect'], $user_ID);
wp_redirect($redirect);
edd_die();
}
}
}
示例10: comber_login_guest
function comber_login_guest()
{
if (isset($_POST['comber_user_login']) && wp_verify_nonce($_POST['comber_login_nonce'], 'comber-login-nonce')) {
// this returns the user ID and other info from the user name
$user = get_userdatabylogin($_POST['comber_user_login']);
if (!$user) {
// if the user name doesn't exist
comber_errors()->add('empty_username', __('Invalid username'));
}
if (!isset($_POST['comber_user_pass']) || $_POST['comber_user_pass'] == '') {
// if no password was entered
comber_errors()->add('empty_password', __('Please enter a password'));
}
// check the user's login with their password
if (!wp_check_password($_POST['comber_user_pass'], $user->user_pass, $user->ID)) {
// if the password is incorrect for the specified user
comber_errors()->add('empty_password', __('Incorrect password'));
}
// retrieve all error messages
$errors = comber_errors()->get_error_messages();
// only log the user in if there are no errors
if (empty($errors)) {
wp_setcookie($_POST['comber_user_login'], $_POST['comber_user_pass'], true);
wp_set_current_user($user->ID, $_POST['comber_user_login']);
do_action('wp_login', $_POST['comber_user_login']);
wp_redirect(home_url($_POST['current_page']));
exit;
} else {
wp_redirect(home_url($_POST['current_page'] . '/?login=true&fail=true'));
exit;
}
}
}
示例11: wpanswer_auth_login
function wpanswer_auth_login($user, $username, $password)
{
global $wpdb, $wpanswer_user_approve;
if (is_a($user, 'WP_User')) {
return $user;
}
//Existing WP core code
$userdata = get_user_by('login', $username);
if (!$userdata) {
return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.', 'wpanswer'));
}
$userdata = apply_filters('wp_authenticate_user', $userdata, $password);
//Existing WP core code
if (is_wp_error($userdata)) {
//Existing WP core code
return $userdata;
}
if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
return new WP_Error('incorrect_password', sprintf(__('<strong>ERROR</strong>: Incorrect password. <a href="%s" title="Password Lost and Found">Lost your password</a>?', 'wpanswer'), site_url('wp-login.php?action=lostpassword', 'login')));
}
//Check if auto pending new account status feature is enabled
if ($wpanswer_user_approve->configs->get_value('wpanswer_enable_manual_registration_approval') == '1') {
$cap_key_name = $wpdb->prefix . 'capabilities';
$user_meta_info = get_user_meta($userdata->ID, 'wpanswer_account_status', TRUE);
if ($user_meta_info == 'pending') {
return new WP_Error('authentication_failed', __('<strong>ACCOUNT PENDING</strong>: Your account is currently not active. An administrator needs to activate your account before you can login.', 'wpanswer'));
}
}
$user = new WP_User($userdata->ID);
return $user;
}
示例12: test
public function test()
{
$users = new UserCollection($this->user['ID'], 'ids');
$user = $users->last;
assert($user->name === 'x');
assert($user->email === 'x@x.x');
assert(wp_check_password($this->user['user_pass'], $user->hash));
}
示例13: um_submit_form_errors_hook_login
function um_submit_form_errors_hook_login($args)
{
global $ultimatemember;
$is_email = false;
$form_id = $args['form_id'];
$mode = $args['mode'];
if (isset($args['username']) && $args['username'] == '') {
$ultimatemember->form->add_error('username', __('Please enter your username or email', 'ultimatemember'));
}
if (isset($args['user_login']) && $args['user_login'] == '') {
$ultimatemember->form->add_error('user_login', __('Please enter your username', 'ultimatemember'));
}
if (isset($args['user_email']) && $args['user_email'] == '') {
$ultimatemember->form->add_error('user_email', __('Please enter your email', 'ultimatemember'));
}
if (isset($args['username'])) {
$field = 'username';
if (is_email($args['username'])) {
$is_email = true;
$data = get_user_by('email', $args['username']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$user_name = $args['username'];
}
} else {
if (isset($args['user_email'])) {
$field = 'user_email';
$is_email = true;
$data = get_user_by('email', $args['user_email']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$field = 'user_login';
$user_name = $args['user_login'];
}
}
if (!username_exists($user_name)) {
if ($is_email) {
$ultimatemember->form->add_error($field, __(' К сожалению, мы не можем найти учетную запись с этим адресом электронной почты', 'ultimatemember'));
} else {
$ultimatemember->form->add_error($field, __(' К сожалению, мы не можем найти учетную запись пользователя с этим', 'ultimatemember'));
}
} else {
if ($args['user_password'] == '') {
$ultimatemember->form->add_error('user_password', __('Пожалуйста введите ваш пароль', 'ultimatemember'));
}
}
$user = get_user_by('login', $user_name);
if ($user && wp_check_password($args['user_password'], $user->data->user_pass, $user->ID)) {
$ultimatemember->login->auth_id = username_exists($user_name);
} else {
$ultimatemember->form->add_error('user_password', __('Неверный пароль. Пожалуйста, попробуйте еще раз.', 'ultimatemember'));
}
}
示例14: um_submit_form_errors_hook_login
function um_submit_form_errors_hook_login($args)
{
global $ultimatemember;
$is_email = false;
$form_id = $args['form_id'];
$mode = $args['mode'];
if (isset($args['username']) && $args['username'] == '') {
$ultimatemember->form->add_error('username', __('Please enter your username or email', 'ultimatemember'));
}
if (isset($args['user_login']) && $args['user_login'] == '') {
$ultimatemember->form->add_error('user_login', __('Please enter your username', 'ultimatemember'));
}
if (isset($args['user_email']) && $args['user_email'] == '') {
$ultimatemember->form->add_error('user_email', __('Please enter your email', 'ultimatemember'));
}
if (isset($args['username'])) {
$field = 'username';
if (is_email($args['username'])) {
$is_email = true;
$data = get_user_by('email', $args['username']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$user_name = $args['username'];
}
} else {
if (isset($args['user_email'])) {
$field = 'user_email';
$is_email = true;
$data = get_user_by('email', $args['user_email']);
$user_name = isset($data->user_login) ? $data->user_login : null;
} else {
$field = 'user_login';
$user_name = $args['user_login'];
}
}
if (!username_exists($user_name)) {
if ($is_email) {
$ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that email address', 'ultimatemember'));
} else {
$ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that username', 'ultimatemember'));
}
} else {
if ($args['user_password'] == '') {
$ultimatemember->form->add_error('user_password', __('Please enter your password', 'ultimatemember'));
}
}
$user = get_user_by('login', $user_name);
if ($user && wp_check_password($args['user_password'], $user->data->user_pass, $user->ID)) {
$ultimatemember->login->auth_id = username_exists($user_name);
} else {
$ultimatemember->form->add_error('user_password', __('Password is incorrect. Please try again.', 'ultimatemember'));
}
}
示例15: validate_password_reset
/**
* Disallow using the same password as before on reset.
*
* @action validate_password_reset
*
* @param WP_Error $errors
* @param WP_User $user
*/
public function validate_password_reset($errors, $user)
{
$new_pass1 = filter_input(INPUT_POST, 'pass1');
$new_pass2 = filter_input(INPUT_POST, 'pass2');
if (!$new_pass1 || !$new_pass2 || $new_pass1 !== $new_pass2 || !Expire_Passwords::has_expirable_role($user)) {
return;
}
$is_same = wp_check_password($new_pass1, $user->data->user_pass, $user->ID);
if ($is_same) {
$errors->add('password_already_used', esc_html__('You cannot reuse your old password.'));
}
}