BuddyBoss Home – Web Support Forums Themes Boss. theme Hiding search box and/or results from logged-out users?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Question

    #35206
    @amy-l-scott

    Just bought Boss today and I’m loving it, thank you!

    I am using the theme on a paid membership site where everything is locked behind a paywall I created with S2 Member.

    While the Global Search is awesome, it’s also visible to people who aren’t logged in, allowing them to see snippets of content that’s only available to members.

    Is there a way to either hide the search entirely when someone isn’t logged in, or have the live preview/search results be hidden?

    Answers

    #35216

    Alyssa
    Participant
    @alyssa-buddyboss

    @amy-l-scott Welcome to the BuddyBoss community! Add this to your child theme functions.php file to remove the search from logged out users:

    if ( ! class_exists( 'DisableSearch' ) && !is_user_logged_in() ) :
    
    class DisableSearch {
    	
    	public static function init() {
    		add_filter( 'get_search_form', array( __CLASS__, 'get_search_form' ), 999 );
    	}
    
    	
    	public static function get_search_form( $form ) {
    		return '';
    	}
    }
    
    DisableSearch::init();
    
    endif;
    #35227
    @amy-l-scott

    Worked like a charm, thank you, @tjchester!

    #35255

    Alyssa
    Participant
    @alyssa-buddyboss

    Anytime 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The question ‘Hiding search box and/or results from logged-out users?’ is closed to new replies.