Skip to content

Instantly share code, notes, and snippets.

@corenominal
Created May 6, 2016 20:28
Show Gist options
  • Save corenominal/3618108554a13ba4885f4c624b4b08bc to your computer and use it in GitHub Desktop.
Save corenominal/3618108554a13ba4885f4c624b4b08bc to your computer and use it in GitHub Desktop.
WordPress action rest_api_init hook to set a global variable for testing whether or not the user is logged in
<?php
function global_is_user_logged_in()
{
global $iewp_crunchstats_logged_in;
$is_user_logged_in = false;
if ( is_user_logged_in() == true )
{
$is_user_logged_in = true;
}
}
add_action( 'rest_api_init', 'global_is_user_logged_in' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment