• I came up with this code snippet and have been using it for a while, but I cannot figure out how to turn it into a plugin for all to enjoy (cannot find the right hooks).

    If you can do it – GO FOR IT!
    Suggestions are welcome too.

    The purpose of the snippet below is to dynamically insert and extra <div> that would indicate whether the user is logged in or not. Then you can apply all kinds of effects via CSS: make certain annoying ads visible only till people log in, change the formatting, etc.

    All I did is insert into the theme header (right after the <body>) this:

    <?php global $userdata ;
    get_currentuserinfo();
    if ($userdata->user_login) :
    ?>
    <div class=”logged_in”>
    <?php endif; ?>

    And then in the footer, right before the <body>:

    <?php global $userdata ;
    if ($userdata->user_login) :
    ?>
    </div class=”logged-in”> <!– end of logged-in –>
    <?php endif; ?>

    The rest is obvious ??
    Unfortunately, wp_head is before the <body>, so I cannot find a hook and make this available for the PHP-disadvantaged ??

Viewing 1 replies (of 1 total)
  • Thread Starter andrabr

    (@andrabr)

    Come to think of it, the generic plug-in should flip between two classes: logged-in and logged-out.

Viewing 1 replies (of 1 total)
  • The topic ‘Take this and make it into a plug-in! Please?’ is closed to new replies.