本文整理汇总了PHP中wp_clear_auth_cookie函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_clear_auth_cookie函数的具体用法?PHP wp_clear_auth_cookie怎么用?PHP wp_clear_auth_cookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_clear_auth_cookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: otl_authenticate_one_time_login
/**
* Process one time login
*
* @since 1.0.0
*
* @return void
*/
function otl_authenticate_one_time_login()
{
// No need to run if not a singular query for the one time login
if (!is_single()) {
return;
}
// No need to run if not a onetimelogin post
global $post;
if ('onetimelogin' !== $post->post_type) {
return;
}
$user_id = get_post_meta(get_the_ID(), 'otl_user', true);
$valid_user = get_userdata($user_id) ? true : false;
$login_uses = get_post_meta(get_the_ID(), 'otl_times_used', true);
// If the one time login is unused and the user is valid, log in
if ('0' === $login_uses && $valid_user) {
// Log in
wp_clear_auth_cookie();
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
// Update some meta for logging and to prevent multiple uses
update_post_meta(get_the_ID(), 'otl_times_used', '1');
update_post_meta(get_the_ID(), 'otl_datetime_used', current_time('mysql'));
// Redirect to wp-admin
wp_safe_redirect(user_admin_url());
exit;
} else {
wp_redirect(home_url());
exit;
}
return;
}
示例2: cps_ban_check
function cps_ban_check()
{
if (!is_user_logged_in()) {
return;
}
global $current_user;
if (is_multisite()) {
if (empty($current_user->roles)) {
load_template(dirname(__FILE__) . '/wp_ban_cps_ms_alert.php');
}
foreach ($current_user->roles as $role) {
if ($role == 'banned') {
load_template(dirname(__FILE__) . '/wp_ban_cps_ms_alert.php');
}
}
} else {
foreach ($current_user->roles as $role) {
if ($role == 'banned') {
wp_clear_auth_cookie();
do_action('wp_logout');
wp_redirect(home_url());
exit;
}
}
}
}
示例3: synlogout
function synlogout($get, $post)
{
!API_SYNLOGOUT && exit(API_RETURN_FORBIDDEN);
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
wp_clear_auth_cookie();
exit(API_RETURN_SUCCEED);
}
示例4: awaycheck
/**
* Redirects to homepage if awaymode is active
*
**/
function awaycheck()
{
global $bwps;
if ($bwps->checkaway()) {
wp_redirect(get_option('siteurl'));
wp_clear_auth_cookie();
}
}
示例5: logout
public function logout(StatTracker $app)
{
wp_clear_auth_cookie();
$app['session']->set("agent", null);
session_destroy();
$response = new stdClass();
$response->status = "logged_out";
$this->logger->info(sprintf("%s logged out", $agent->name));
return $response;
}
示例6: logout_idle_user
function logout_idle_user()
{
if (is_user_logged_in()) {
do_action('uil_before_logout', get_current_user_id());
}
delete_user_meta(get_current_user_id(), 'last_active_time');
wp_clear_auth_cookie();
do_action('uil_after_logout');
die('true');
}
示例7: run_active_check
/**
* Execute away mode functionality
*
* @return void
*/
public function run_active_check()
{
global $itsec_logger;
//execute lockout if applicable
if (self::is_active()) {
$itsec_logger->log_event('away_mode', 5, array(__('A host was prevented from accessing the dashboard due to away-mode restrictions being in effect', 'better-wp-security')), ITSEC_Lib::get_ip(), '', '', '', '');
wp_redirect(get_option('siteurl'));
wp_clear_auth_cookie();
die;
}
}
示例8: login
/**
* Login existing WP user.
*
* @param $wp_user
*/
public function login($wp_user)
{
// Login procedure.
wp_clear_auth_cookie();
wp_set_current_user($wp_user->ID);
wp_set_auth_cookie($wp_user->ID);
// Hook for changing WP user metadata from Gigya's user.
do_action('gigya_after_social_login', $this->gigya_user, $wp_user);
// Do others login Implementations.
do_action('wp_login', $wp_user->data->user_login, $wp_user);
}
示例9: login
function login($login, $password)
{
wp_clear_auth_cookie();
$creds = array();
$creds['user_login'] = $login;
$creds['user_password'] = $password;
$creds['remember'] = false;
$user = wp_signon($creds, false);
if (is_wp_error($user)) {
die("Invalid user name or password");
}
}
示例10: login
/**
* Login existing WP user.
*
* @param $wp_user
*/
public function login($wp_user)
{
// Login procedure.
wp_clear_auth_cookie();
wp_set_current_user($wp_user->ID);
wp_set_auth_cookie($wp_user->ID);
_gigya_add_to_wp_user_meta($this->gigya_account['profile'], $wp_user->ID);
// Hook for changing WP user metadata from Gigya's user.
do_action('gigya_after_raas_login', $this->gigya_account, $wp_user);
// Do other login Implementations.
do_action('wp_login', $wp_user->data->user_login, $wp_user);
}
示例11: log_user
static function log_user($user_id)
{
$user = get_user_by('id', $user_id);
// Redirect URL //
if (!is_wp_error($user)) {
wp_clear_auth_cookie();
wp_set_current_user($user->ID);
wp_set_auth_cookie($user->ID);
return TRUE;
}
return FALSE;
}
示例12: user_login
public function user_login()
{
$response = array('redirect' => false, 'request' => $_POST);
//Check for empty fields
if (empty($_POST['email']) || empty($_POST['pwd'])) {
//create new error object and add errors to it.
$error = new WP_Error();
if (empty($email)) {
//No email
$error->add('empty_username', __('<strong>ERROR</strong>: Email field is empty.'));
} else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
//Invalid Email
$error->add('invalid_username', __('<strong>ERROR</strong>: Email is invalid.'));
}
}
if (empty($meta['password'])) {
//No password
$error->add('empty_password', __('<strong>ERROR</strong>: Password field is empty.'));
}
$response['errors'] = $error;
}
if (empty($response['errors'])) {
$email = $_POST['email'];
$meta['password'] = $_POST['pwd'];
//Check if user exists in WordPress database
$user = get_user_by('email', $email);
//bad email
if (!$user) {
$error = new WP_Error();
$error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.'));
$response['errors'] = $error;
} else {
//check password
if (!wp_check_password($meta['password'], $user->user_pass, $user->ID)) {
//bad password
$error = new WP_Error();
$error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.'));
$response['errors'] = $error;
} else {
wp_clear_auth_cookie();
wp_set_current_user($user->ID);
wp_set_auth_cookie($user->ID);
$response['redirect'] = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : home_url();
$response['user'] = $user;
}
}
}
echo json_encode($response);
exit;
}
示例13: pc_wp_user_login
function pc_wp_user_login($user_login, $user)
{
global $wpdb;
global $pc_wp_user;
// do not execute if is a pvtcontent login
if (!isset($GLOBALS['pc_wps_standard_login'])) {
$user_data = $pc_wp_user->wp_user_is_linked($user->ID);
if ($user_data) {
// PC-FILTER - custom login control for custom checks - passes false and user id - return message to abort login otherwise false
$custom_check = apply_filters('pc_login_custom_check', false, $user_data->id);
// check status
if ((int) $user_data->status !== 1 || $custom_check !== false) {
// Clear cookies -> log user out
wp_clear_auth_cookie();
$error_param = $custom_check !== false ? $custom_check : $user_data->status;
// redirect adding disabling parameter - for pc_wp_user_login_message() function
$login_url = site_url('wp-login.php', 'login');
$login_url = add_query_arg('pc_disabled', $error_param, $login_url);
wp_redirect($login_url);
exit;
} else {
include_once PC_DIR . '/functions.php';
//// login in pvtContent
// setup user session, cookie and global
$_SESSION['pc_user_id'] = $user_data->id;
$GLOBALS['pc_user_id'] = $user_data->id;
// set cookie
$cookie_time = isset($_POST['rememberme']) ? 3600 * 24 * 30 * 6 : 3600 * 6;
// 6 month or 6 hours
setcookie('pc_user', $user_data->id . '|||' . $user_data->psw, time() + $cookie_time, '/');
// update last login date
$wpdb->update(PC_USERS_TABLE, array('last_access' => current_time('mysql')), array('id' => $user_data->id));
//// redirect after login
// check for custom categories redirects
$custom_cat_redirect = pc_user_cats_login_redirect($user_data->categories);
if ($custom_cat_redirect) {
$redirect_url = $custom_cat_redirect;
} else {
if (get_option('pg_logged_user_redirect')) {
$redirect_url = pc_man_redirects('pg_logged_user_redirect');
} else {
$redirect_url = site_url();
}
}
wp_redirect($redirect_url);
exit;
}
}
}
}
示例14: wppb_autologin_after_password_changed
function wppb_autologin_after_password_changed()
{
if (isset($_POST['action']) && $_POST['action'] == 'edit_profile') {
if (isset($_POST['passw1']) && !empty($_POST['passw1']) && !empty($_POST['form_name'])) {
/* all the error checking filters are defined in each field file so we need them here */
if (file_exists(WPPB_PLUGIN_DIR . '/front-end/default-fields/default-fields.php')) {
require_once WPPB_PLUGIN_DIR . '/front-end/default-fields/default-fields.php';
}
if (file_exists(WPPB_PLUGIN_DIR . '/front-end/extra-fields/extra-fields.php')) {
require_once WPPB_PLUGIN_DIR . '/front-end/extra-fields/extra-fields.php';
}
/* we get the form_name through $_POST so we can apply correctly the filter so we generate the correct fields in the current form */
$form_fields = apply_filters('wppb_change_form_fields', get_option('wppb_manage_fields'), array('form_type' => 'edit_profile', 'form_fields' => array(), 'form_name' => $_POST['form_name'], 'role' => '', 'ID' => Profile_Builder_Form_Creator::wppb_get_form_id_from_form_name($_POST['form_name'], 'edit_profile')));
if (!empty($form_fields)) {
/* check for errors in the form through the filters */
$output_field_errors = array();
foreach ($form_fields as $field) {
$error_for_field = apply_filters('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug($field['field']), '', $field, $_POST, 'edit_profile');
if (!empty($error_for_field)) {
$output_field_errors[$field['id']] = '<span class="wppb-form-error">' . $error_for_field . '</span>';
}
}
/* if we have no errors change the password */
if (empty($output_field_errors)) {
$user_id = get_current_user_id();
if (!is_multisite() && current_user_can('edit_users') || is_multisite() && current_user_can('manage_network')) {
if (isset($_GET['edit_user']) && !empty($_GET['edit_user'])) {
$user_id = $_GET['edit_user'];
}
}
if (!isset($_GET['edit_user'])) {
wp_clear_auth_cookie();
/* set the new password for the user */
wp_set_password($_POST['passw1'], $user_id);
// Here we calculate the expiration length of the current auth cookie and compare it to the default expiration.
// If it's greater than this, then we know the user checked 'Remember Me' when they logged in.
$logged_in_cookie = wp_parse_auth_cookie('', 'logged_in');
/** This filter is documented in wp-includes/pluggable.php */
$default_cookie_life = apply_filters('auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, false);
$remember = $logged_in_cookie['expiration'] - time() > $default_cookie_life;
wp_set_auth_cookie($user_id, $remember);
} else {
wp_set_password($_POST['passw1'], $user_id);
}
}
}
}
}
}
示例15: purge_browser_cookie
/**
* Clear the authentication cookies.
*
* @param array|string $cookie The current authentication cookie.
*/
public static function purge_browser_cookie($cookie)
{
// Remove the action to prevent recursion with some plugins (notably s2member)
remove_action(current_action(), array(__CLASS__, __FUNCTION__));
/*
* Sometimes the cookie is empty because WordPress uses multiple types of auth cookies.
* When one of the cookies is empty, we don't want to purge the cookies because other
* cookies may have us legitimately logged in *and* empty cookies (e.g., unset) aren't
* doing the cache-busting that prompts us to want to purge.
*/
if (empty($cookie)) {
return;
}
wp_clear_auth_cookie();
}