Function to check if user is logged in is is_user_logged_in(). It would return true if user is logged in and false otherwise.
Function reference: is_user_logged_in
Example – iNove theme – footer.php file
By default Google Analytics code is displayed to everyone:
<?php
wp_footer();
$options = get_option('inove_options');
if ($options['analytics']) {
echo($options['analytics_content']);
}
?>
After change the code is displayed only if user is not logged in:
<?php
wp_footer();
$options = get_option('inove_options');
if ($options['analytics'] and !is_user_logged_in()) {
echo($options['analytics_content']);
}
?>