I have a few pages on the frontend of my site in which my users author content. This content can take many hours to create. Unfortunately, my site has a 4-hour session limit, and by the time my users submit their content (via web forms), they have been logged out, they are redirected to the login page, and their content is lost.

In the admin panel, particularly on the "Pages" page, there is a lightboxed login form (interim login) that displays the famous "Session expired. Please log in again. You will not move away from this page." message. The message shows up as soon as the session limit has been reached. How can I use this built-in functionality on all front end pages of my site?

  • If your users so often need more time, why not increase the session limit?
    – Caspar
    Apr 14 '16 at 20:31
  • Hi Caspar, The limit is set at 4 hours as a security measure for the majority of my users. A select few of my users have access to a page on which they can create content that takes longer than four hours. I would like to allow them to log in again from their content-authoring page when their session expires. However, this is a feature that would be great to have on all pages, so I would prefer a solution that works on all frontend pages.
    – valentine
    Apr 14 '16 at 20:48

Here is a short plugin that adds the interim-login lightbox on every frontend page:


Plugin Name: Interim Login Everywhere
Version: 1.0.1
Plugin URI: http://nowhere.com
Description: Provide interim login screens on all pages.
Author: S Valentine


function ile_enqueue_scripts() {
    // we only care to add scripts and styles if the user is logged in.
    if ( is_user_logged_in() ) {

        // add javascript file
        wp_register_script( 'wp_auth_check', '/wp-includes/js/wp-auth-check.js' , array('heartbeat'), false, 1);
        wp_localize_script( 'wp_auth_check', 'authcheckL10n', array(
            'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'),
            'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ), // default interval is 3 minutes
        ) );
        wp_enqueue_script ('wp_auth_check');

        // add css file
        wp_enqueue_style( 'wp_auth_check','/wp-includes/css/wp-auth-check.css', array( 'dashicons' ), NULL, 'all' );

        // add the login html to the page
        add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 );
add_action( 'wp_enqueue_scripts', 'ile_enqueue_scripts' );

// make sure the stylesheet appears on the lightboxed login iframe
function ile_enqueue_login_scripts() {
    wp_enqueue_style( 'wp_auth_check','/wp-includes/css/wp-auth-check.css', array( 'dashicons' ), NULL, 'all' );
add_action( 'login_enqueue_scripts', 'ile_enqueue_login_scripts' );


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.