Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wc php after login redirect page

// start global session for saving the referer url
function start_session() {
    if(!session_id()) {
        session_start();
    }
}
add_action('init', 'start_session', 1);

// get  referer url and save it 
function redirect_url() {
    if (! is_user_logged_in()) {
        $_SESSION['referer_url'] = wp_get_referer();
    } else {
        session_destroy();
    }
}
add_action( 'template_redirect', 'redirect_url' );

//login redirect 
function login_redirect() {
    if (isset($_SESSION['referer_url'])) {
        wp_redirect($_SESSION['referer_url']);
    } else {
        wp_redirect(home_url());
    }
}
add_filter('woocommerce_login_redirect', 'login_redirect', 1100, 2);
Comment

PREVIOUS NEXT
Code Example
Php :: Add class to menu anchors 
Php :: yajra add column 
Php :: messagebird php curl send sms example 
Php :: dql if or ifnull 
Php :: strtolower cyrillic 
Php :: null php 
Php :: php variables as keys in arrays 
Php :: Returning JSON from a PHP Script 
Php :: find largest element of an array in php 
Php :: php multiple array to single array 
Php :: php api call with headers 
Php :: what should write for getting extension of image in php 
Php :: run php with xampp 
Php :: phpunit/phpunit[6.0.0, ..., 6.5.14] require php ^7.0 - your php version (8.0.0) does not satisfy that requirement. 
Php :: define value in php 
Php :: unexpected end of file php 
Php :: 12 hrs for preg match with single and double digit in php 
Php :: laravel edit 
Java :: convert string to localdatetime 
Java :: copy to clipboard java 
Java :: priority queue reverse order java 
Java :: fullscreen activity android 
Java :: springboot starter jpa 
Java :: java random boolean 
Java :: Could not find any matches for com.transistorsoft:tsbackgroundfetch:+ as no versions of com.transistorsoft:tsbackgroundfetch are available. 
Java :: is grepper legit 
Java :: random string method java 
Java :: how to format ddmmmyyyy to ddmmyy in java 
Java :: keypressed java space 
Java :: android up navigation 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =