Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide forum from logged in users


  • demonboy
    Participant

    @demonboy

    Hi,

    Strange request but I would like to hide a forum completely when the user is logged in. This is because I’m using this forum as an info page for new visitors. Once a user is registered and logged in, they don’t need to see the forum, so I’d like to remove the entire < ul >. I’m hoping this is a simple addition to my functions.php file, something along the lines of:

    if ( bbp_is_user_logged_in() ) {
       echo "<some css that did ul.bbp-forum-40250 {display:none;}
    }

    Except I know that’s probably not the best way to achieve this. What would be the best way to hide the forum to logged in users?

    Thanks.

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

  • Robin W
    Moderator

    @robin-w

    If you just want to remove it from the list then you could amend loop-single-forum.php

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-forum.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-single-forum.php
    bbPress will now use this template instead of the original
    and you can amend this

    change it to (assuming 40250 is the fiorum id)

    
    <?php
    
    /**
     * Forums Loop - Single Forum
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    if ( !bbp_get_forum_id() == '40250')) {
    ?>
    
    <ul id="bbp-forum-<?php bbp_forum_id(); ?>" <?php bbp_forum_class(); ?>>
    
    	<li class="bbp-forum-info">
    
    		<?php if ( bbp_is_user_home() && bbp_is_subscriptions() ) : ?>
    
    			<span class="bbp-row-actions">
    
    				<?php do_action( 'bbp_theme_before_forum_subscription_action' ); ?>
    
    				<?php bbp_forum_subscription_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '&times;' ) ); ?>
    
    				<?php do_action( 'bbp_theme_after_forum_subscription_action' ); ?>
    
    			</span>
    
    		<?php endif; ?>
    
    		<?php do_action( 'bbp_theme_before_forum_title' ); ?>
    
    		<a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"><?php bbp_forum_title(); ?></a>
    
    		<?php do_action( 'bbp_theme_after_forum_title' ); ?>
    
    		<?php do_action( 'bbp_theme_before_forum_description' ); ?>
    
    		<div class="bbp-forum-content"><?php bbp_forum_content(); ?></div>
    
    		<?php do_action( 'bbp_theme_after_forum_description' ); ?>
    
    		<?php do_action( 'bbp_theme_before_forum_sub_forums' ); ?>
    
    		<?php bbp_list_forums(); ?>
    
    		<?php do_action( 'bbp_theme_after_forum_sub_forums' ); ?>
    
    		<?php bbp_forum_row_actions(); ?>
    
    	</li>
    
    	<li class="bbp-forum-topic-count"><?php bbp_forum_topic_count(); ?></li>
    
    	<li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? bbp_forum_reply_count() : bbp_forum_post_count(); ?></li>
    
    	<li class="bbp-forum-freshness">
    
    		<?php do_action( 'bbp_theme_before_forum_freshness_link' ); ?>
    
    		<?php bbp_forum_freshness_link(); ?>
    
    		<?php do_action( 'bbp_theme_after_forum_freshness_link' ); ?>
    
    		<p class="bbp-topic-meta">
    
    			<?php do_action( 'bbp_theme_before_topic_author' ); ?>
    
    			<span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>
    
    			<?php do_action( 'bbp_theme_after_topic_author' ); ?>
    
    		</p>
    	</li>
    
    </ul><!-- #bbp-forum-<?php bbp_forum_id(); ?> -->
    
    <?php } ?>

    Not tested but should work, if not then might be another bbpress plugin overwriting the template – come back


    demonboy
    Participant

    @demonboy

    Hey Robin,

    Thanks for getting back to me. I’ve just this moment found a simple solution. What do you think of this:

    .logged-in #bbp-forum-40250 {
    	display: none;
    }

    Robin W
    Moderator

    @robin-w

    yes that looks like a good solution !


    demonboy
    Participant

    @demonboy

    Thanks, Robin, and thank you for your (free) support on the bbpress forums. Appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar