• I want to display conditional welcome text on my main page. So that is the user is logged in they will get a “Welcome Back [UserName]…” text, but if they are not logged in they will get, “You are currently not logged in, please login or register.”

    How do I do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter ebaltz

    (@ebaltz)

    I figured this one out, just did a quick if else PHP.

    I could use this – care to share the PHP with me? I am great at following directions & cut/paste, but do not understand PHP at all.

    Give me a “find SKLDJHF and change to LKFOITR” and I’m good!

    <?php
    
    global $user_login, $user_identity;
    get_currentuserinfo();
    if ($user_login) :
    ?>
    <h2>Welcome Back <?php echo $user_identity; ?>!</h2>
    
       <ul> <?php
    $date = date("D M j G:i:s Y", time()+60*60*$diff=-3);
    print ($date);
    ?>
       <br /><?php wp_register(); ?><br />
       <a href="<?php echo get_settings('siteurl') . '/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']; ?>"><?php _e('Logout'); ?></a>
        </ul>
    
        DO LOGGED IN STUFF HERE
    
    <?php else : ?>
    <li><h2>Welcome Guest! </h2>
    
    Please Login or <?php wp_register('', ''); ?> for member's benefits.<br />
        <form name="loginform" id="loginform" action="<?php echo get_settings('siteurl'); ?>/wp-login.php" method="post">
        <label><?php _e('Login') ?>:&nbsp;&nbsp;<input type="text" name="log" id="log" value="" size="10" maxlength="30" tabindex="7" /></label><br /><br />
        <label><?php _e('Password') ?>:&nbsp;&nbsp;<input type="password" name="pwd" id="pwd" value="" size="10" maxlength="30" tabindex="8" /></label><br /><br />
        <input type="hidden" name="rememberme" value="forever" />
        <center><input type="submit" name="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="9" /></center>
        <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
        </form>
    <?php endif; ?>

    Wow – that was fast!

    Now I need to know how to use it. I think I cut/paste it into a PHP file. Which one?

    Do I need to put some code somewhere else to activate this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Conditional text based on login’ is closed to new replies.