Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created November 7, 2013 16:36
Show Gist options
  • Save strangerstudios/7357594 to your computer and use it in GitHub Desktop.
Save strangerstudios/7357594 to your computer and use it in GitHub Desktop.
Add ?loggedoutview=1 to the end of any URL to see what it looks like for logged out users.
<?php
/*
Plugin Name: Logged Out View
Plugin URI: http://www.strangerstudios.com/wp/logged-out-view/
Description: Add ?loggedoutview=1 to the end of any URL to see what it looks like for logged out users.
Author: Stranger Studios
Version: .1
Author URI: http://www.strangerstudios.com
*/
function lov_set_current_user()
{
if(!empty($_REQUEST['loggedoutview']))
{
global $current_user;
if(!empty($current_user) && $current_user->ID > 0)
wp_set_current_user( 0 );
}
}
add_action('set_current_user', 'lov_set_current_user');
@strangerstudios
Copy link
Author

Possible improvement:
(1) persisting the ?loggedoutview parameter (hint: use home_url and site_url hooks and add query arg())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment