A

Show content on basis of logged in status of users in bbPress

No 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) Example #2 (Show some content only if […]

No 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.

13 responses to “Show content on basis of logged in status of users in bbPress”

  1. jj says:

    hi

    where i must pt those code? in which file?

    thanks

  2. jj says:

    ok
    I have edited forum.php and put the code inside but it doesn’t work, the content is still visible for unregistred users. I suppose i’m doing something wrong. Maybe i dont add the code where i should.
    Do i need to put something in particular between:
    /* Add the private content here or some code */

    • Ashfame says:

      yes! the code responsible for generating content should come in between it. If you are just trying to make your forum members only, then there are better approaches. If you just want to hide the content and display a message, you are on the right track.

  3. jj says:

    ok my mistake!
    I’m precisly trying to do a topic for members only.
    Sorry about that. If you have any tips on this matter, let me know 🙂

    thank you

  4. turunc4u says:

    Hi, I want manual content to hide. Example I share some links in movie download topic but I want only registered user can see link. Is it possible. If you want to download links please sign up forum.