Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding objects from registered and unregistered users.

  • I’d like to hide the login/pass fields after a user has logged in and there are some other things I would like to hide or be available only to registered users.

    Can anyone help?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Ok, I so figured out the <?php if ( bb_is_user_logged_in() ) : ?> tags to display items to users that are logged in. Now how can it be used to hide things from people that are logged in?

    There is a lack of documentation on functions it seems. That or I’m just not looking in the right places.

    Not tried this but usually with functions you can put in an exclamation mark in to what you had for not logged in.

    <?php if ( !bb_is_user_logged_in() ) { ?>

    show to those not logged in

    <?php } ?>

    Sorry if that’s obvious and you’ve already tried it.

    Thank you!

    I’m still a little new at this so I appreciate the help with what was more then likely a very simple question. It worked after I modified it a little.

    <?php if ( !bb_is_user_logged_in() ) : ?>

    show to those not logged in

    <?php endif; ?>

    In which file should I make the modification <?php if ( bb_is_user_logged_in() ) : ?> and where so that unregistered users CANNOT see the forums or the topics?

    Hi, dan90036

    Try this:

    <?php if ( bb_is_user_logged_in() ) : ?>
    HTML content for registred user
    <?php else : ?>
    HTML content for unregistred user
    <?php endif; // bb_is_user_logged_in() ?>

    Thank you Ohna, one question in which file and where should I put this snippet of code?

    Dan

    I think this isn’t the best practice but you can try this for the moment:

    If you use a custom template, edit with a text editor:

    my-templates/(name_of_your_templates)/front-page.php

    after:

    <?php bb_get_header(); ?>

    add:

    <?php if ( bb_is_user_logged_in() ) : ?>

    before :

    <?php bb_get_footer(); ?>

    add :

    <?php else : ?>
    <?php if ( !in_array( bb_get_location(), array( 'login-page', 'register-page' ) ) ) login_form(); ?>
    <?php endif; // bb_is_user_logged_in() ?>

    do the same for:

    my-templates/(name_of_your_templates)/topic.php

    my-templates/(name_of_your_templates)/forum.php

    my-templates/(name_of_your_templates)/profile.php

    my-templates/(name_of_your_templates)/tags.php

    my-templates/(name_of_your_templates)/tag-single.php

    my-templates/(name_of_your_templates)/view.php

    but your forums posts can allways be read trough the rss feed..

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.