I'd like to build some conditionals in to my WordPress theme. A simple check I've used before while displaying content to a logged in user is: is_user_logged_in if ( is_user_logged_in() ) { echo 'Member Dashboard Link'; } else { // shhh, say nothing! } http://codex.wordpress.org/Function_Reference/is_user_logged_in When I login as a user, it doesn't seem to recognize me as logged in! I know the widget seems to work, but I want more control of the members experience ... and do some cool theme tricks based on whether the member is logged in/out. Anyone have this working?
@davidm1, thanks for you reply. Not with in the post / page content, but with in the theme. Say for example: I have two 'menus' to show in the header. 1. Member Center Dashboard ( user logged in ) 2. Sign up | Login ( user logged out ) or on the home page: Code: <?php if ( is_user_logged_in() ) : // Member logged in ?> Member Home: Resources <?php else: // Member not logged in ?> Guest Home : Sign up <?php endif ?> I understand I can do some of this with [shortcodes] - I want to be able to do it on the wordpress theme level.
amember plugin widgets and protection system do not require user to be logged in wordpress. It use aMember sessions instead. If after login is_user_logged_in() function does not work right - single login does not work between aMember and wordpress. Check all security key values in aMember CP -> Setup -> Wordpress and make sure they are the same as in wordpress config file. Also make sure that both wordpress and aMember use the same domain name in urls. For example if user login into aMember at www.domain.com and then redirected to wordpress at domain.com single login will not work in most cases because domains are different. In any way you can use amember's code in order to check is user logged in amember or not: PHP: <?php if(am4PluginsManager::getAPI()->isLoggedIn()) : // Member logged in ?> Member Home: Resources <?php else: // Member not logged in ?> Guest Home : Sign up <?php endif ?>
Alexander, Thanks for your suggestions and code! I did get the results I was looking for with your code above. I may have to request support to have you review our aM +WP setup - aM's still (not really) logging members into WP.
Hi, Would it be possible to expand on this slightly please? Basically, the above code is exactly what I was looking for. However, would the same code work in Xenforo? Also, what would the code be for username, so when the user is logged in, I could write something like Welcome back {username here}
In xenforo you can use it's own template variables. For example: http://xenforo.com/community/threads/1-0-0-b1-finding-variables-available-to-templates.6071/