Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding objects from registered and unregistered users.


  • Thrift
    Member

    @thrift

    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)

  • Thrift
    Member

    @thrift

    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.


    Ziyphr
    Member

    @ziyphr

    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.


    Thrift
    Member

    @thrift

    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; ?>


    dan90036
    Member

    @dan90036

    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?


    Ohna
    Member

    @ohna

    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() ?>


    dan90036
    Member

    @dan90036

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

    Dan


    Ohna
    Member

    @ohna

    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.