Show content on basis of logged in status of users in bbPress
September 5th, 2009 | Tagged as: bbPress | Download as PDFNo big deal here, just basic php stuff here. Here I will show how to use bb_is_user_logged_in function to dynamically produce output on the basis that the user is logged in or not.
Example #1 (Show ads only for non-logged in members and not for logged in members)
<?php
if ( bb_is_user_logged_in() ) {
/* Add adsense or other ad code here*/
}?>
Example #2 (Show some content only if the user is logged in)
<?php
if ( bb_is_user_logged_in() ) {
/* Add the private content here or some code */
}?>
Example#3 (Do more stuff)
<?php
if ( bb_is_user_logged_in() ) {
/* You are logged in – do something for members */
}
else {
/* You are not logged in – do something for guests */
}?>
So you can do anything on the basis that the current user is logged in or not. Need more help? Ask in the comments and I will be glad to help you out.




Howdy! My name is Ashish K Saini aka Ashfame.
