Skip to content

Instantly share code, notes, and snippets.

@danielmcclure
Last active August 29, 2015 14:18
Show Gist options
  • Save danielmcclure/5b277f0f0553a584aa7f to your computer and use it in GitHub Desktop.
Save danielmcclure/5b277f0f0553a584aa7f to your computer and use it in GitHub Desktop.
Shortcode To Only Display Content When User Is Logged In / Out
//* Add logged in content shortcode
function tme_is_logged_in ($params, $content = null) {
if ( is_user_logged_in() ){
return $content;
} else {
return;
}
}
add_shortcode('isloggedin', 'tme_is_logged_in' );
//* Add logged out content shortcode
function tme_is_logged_out ($params, $content = null) {
if ( !is_user_logged_in() ){
return $content;
} else {
return;
}
}
add_shortcode('isloggedout', 'tme_is_logged_out' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment