I am looking to do the same thing, if you find a solution then please let me know:)
Wrap a button in if ( is_user_logged_in() ) { and }. Only logged in users will see it.
Hey Boone, is there a way to do something like if a logged in user clicks the button he goes to /blabla and if a guest clicks the button he goes to /registerfirst?
Add an else statement to the code Boone posted.
<?php if(is_user_logged_in()) : ?>
<a href="LINK TO WHERE YOU WANT THE LOGGED IN USER TO GO"><img src="YOUR BUTTON" alt="" /></a>
<?php else : ?>
<a href="LINK TO WHERE YOU WANT PEOPLE WHO ARE NOT LOGGED IN TO GO"><img src="YOUR BUTTON" alt="" /></a>
<?php endif; ?>
Sorry for the caps!
They might work for a button but, what about a function like so……
//*********Site Navigation*********//
function site_nav_links(){ ?>
Explore
<ul class=”your-ul-list-css-classname”>
Blog
Members
<li class=”alt”>Groups
Forums
<li class=”alt”>Blogs
<?php
}
I tried a hundred ways and all I get is a white screen. I am not sure if I am writing the loggin user part correctly or not. The above function works well for the public but, once you try to hide it from the public it goes blank. I have almost given up.
Use backticks to add code, or better yet, use pastebin.com