WordPress.org

Forums

Peter's Login Redirect
Is this possible? (2 posts)

  1. WMEric
    Member
    Posted 1 year ago #

    I was just wondering if was possible to add a JS alert or Modal stating that the user has been logged out successfully or perhaps would it just be easier to do a separate page?

    Thanks

    https://wordpress.org/plugins/peters-login-redirect/

  2. Chris Dillon
    Member
    Posted 1 year ago #

    A separate page would be the simpler approach. But here's a way to do it with a JavaScript alert box (taken from this approach).

    Add a trigger to a logout rule like this:

    [variable]siteurl[/variable]?loggedout=true

    and add this to your theme's functions.php:

    function plr_logout_alert()
    {
      if( 'true' == $_GET['loggedout'] )
      {
        echo '<script>alert("You have been logged out.");</script>';
      }
    }
    add_action( 'init', 'plr_logout_alert' );

    The downsides are
    (1) the user will see mysite.com?loggedout=true in the address bar, and
    (2) the page is not displayed until they dismiss the alert box.

    There are more advanced ways of passing messages onto the next page - let me know if you're interested and I'll cook something up.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Peter's Login Redirect
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.