Code help

I’m creating a little plugin that outputs some html. Here’s what I got so far. Displays the html on all blogs except the main one. What/Where do I need to add code so that it doesn’t display to logged in users.

if ( !defined("ABSPATH") ) {
die("I don't think so, Tim.");
}

global $blog_id;

if ( $blog_id == 1 ) {
return;
}

function test_function () { ?>

<!--HTML CODE HERE -->

<?php }

add_action('wp_footer', test_function');

Thanks

  • Hiranthi
    • Recruit

    This

    if ( !defined("ABSPATH") ) {

    die("I don't think so, Tim.");

    }

    global $blog_id;

    if ( $blog_id == 1 ) {

    return;

    }

    function test_function () { ?>

    <!--HTML CODE HERE -->

    <?php }

    add_action('wp_footer', test_function');

    ?>

    Should be this:

    if ( !defined("ABSPATH") ) {

    die("I don't think so, Tim.");

    }

    global $blog_id;

    if ( $blog_id == 1 ) {

    return;

    }

    function test_function () {

    if ( !is_user_logged_in() ) { ?>

    <!-- HTML CODE HERE -->

    <?php

    }

    }

    add_action('wp_footer', test_function');

    ?>

    And you could probably also use this (instead of the above code):

    if ( !defined("ABSPATH") ) {

    die("I don't think so, Tim.");

    }

    global $blog_id;

    if ( $blog_id == 1 ) {

    return;

    }

    function test_function () { ?>

    <!--HTML CODE HERE -->

    <?php }

    global $user_ID;

    get_currentuserinfo();

    if ( '' == $user_ID ) {

    add_action('wp_footer', test_function');

    }

    ?>

    More can be found on the wp_get_current_user page at WP.org