Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how do i logout wordpress without confirmation

add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
    /**
     * Allow logout without confirmation
     */
    if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
        $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'url-you-want-to-redirect';
        $location = str_replace('&', '&', wp_logout_url($redirect_to));
        header("Location: $location");
        die;
    }
}
Comment

logout wp without confirmation

/**
 * Generates custom logout URL
 */
function getLogoutUrl($redirectUrl = ''){
    if(!$redirectUrl) $redirectUrl = site_url();
    $return = str_replace("&", '&', wp_logout_url($redirectUrl));
    return $return;
}

/**
 * Bypass logout confirmation on nonce verification failure
 */
function logout_without_confirmation($action, $result){
    if(!$result && ($action == 'log-out')){ 
        wp_safe_redirect(getLogoutUrl()); 
        exit(); 
    }
}
add_action( 'check_admin_referer', 'logout_without_confirmation', 1, 2);
Comment

PREVIOUS NEXT
Code Example
Php :: php var dump die 
Php :: validate timestamp php 
Php :: isset submit in php 
Php :: whats the meaninig of void functions in php 
Php :: how check if variable is resgister in laravel 
Php :: Zend Framework 2 in a ZF1 project 
Php :: MForm Attribute für Felder 
Php :: Search WordPress with custom field 
Php :: php form detect if number has decimals 
Php :: unique laravel migration 
Php :: laravel create model with migration and resource controller 
Php :: age php datetime 
Php :: to paste file in opt/lampp 
Php :: get current route laravel 
Php :: how to check if input is number only in php 
Php :: incorrect format parameter phpmyadmin xampp 
Php :: shoulder blade technical name 
Php :: php import function from another file 
Php :: console.log in php 
Php :: Redaxo new Mform all fields - input fields - PHP 8+ - MForm 7.0+ 
Php :: php pdo set charset 
Php :: encryp with codeigniter 3 
Php :: how to restart php-fpm on ubuntu 
Php :: php access json object 
Php :: Laravel 8: seed users + Jetstream teams 
Php :: laravel create project thorugh composer 
Php :: create admin password in magento 2 
Php :: php get all values from associative array 
Php :: cmd run powershell command 
Php :: webstorm vs phpstorm 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =