Hey Everyone, I'm pretty novice when it comes to understanding php code, so it came to the point where, something i'm sure is quite simple, has me scratching my head. This is what im trying to accomplish. When a user is logged in then the message Welcome Registered Guest... & the function <?php echo wp_logout_url(); ?> is displayed, and when there not then it displays the log in function and Welcome Visitor. <?php if ( is_user_logged_in() ) { echo 'Welcome, registered user!'; echo '<a href="<?php echo wp_logout_url(); ?>" title="Logout">Logout</a>'; } else { echo 'Welcome, visitor!'; echo '<a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>'; }; ?> PHP: Anyone have an idea of how i can do this? Thanks, http://www.filmhammer.com
Below is the correct code ... <?php if ( is_user_logged_in() ) { echo 'Welcome, registered user!'; echo '<a href="'.wp_logout_url().'" title="Logout">Logout</a>'; } else { echo 'Welcome, visitor!'; echo '<a href="'.wp_login_url( get_permalink() ).'" title="Login">Login</a>'; } ?> Code (markup):
I don't s'pose you know how to wrap a div around this function ' wp_login_form();' in the code do you? <?php if ( is_user_logged_in() ) { wp_login_form(); echo 'Welcome, visitor!'; echo '<div class="art-admin"><a href="'.wp_logout_url().'" title="Logout">Logout</a></div>'; echo '<div class="art-admin"><a href="'.get_admin_url().'" title="Admin">Admin</a></div>'; } else { echo '<a href="'.wp_login_url( get_permalink() ).'" title="Login">Login</a>'; } ?> PHP: