Continuing this - Remove Search Box for non-logged-in-users

Started a thread here on this
https://premium.wpmudev.org/forums/topic/remove-search-boxes-for-non-logged-in-users

Opening a new thread. Hopefully this will keep things clear.

I started with help in chat on this and now continuing here in the forums.

Still trying to disallow the not logged in folks from accessing the buddypress search as this is only a service I want only logged in users to access.

I changed sidebar-bphome.php line 62
from this
<?php if ( bp_search_form_enabled() ) : ?>

to this
<?php if ( bp_search_form_enabled() && is_user_logged_in() ) : ?>

I still see the search box. Image attached.

This is bp-daily 3.9.6 and buddypress 1.2.7

  • drdave
    • The Crimson Coder

    The code above I mentioned was recommended by mohanjith and upon verifying it appears correct. The one you recommended already tried no go.

    <?php if ( is_user_logged_in() ) : ?>
    Appears to be pretty much standard and what I usually use in situation like these but it did not work in this case.

  • drdave
    • The Crimson Coder

    First recommendation by mohanjith placed in sidebar-bphome.php in root of child copied from parent

    <?php if ( bp_search_form_enabled() && is_user_logged_in() ) : ?>
    <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form"><input type="text" id="search-terms" name="search-terms" value="" size="18"/>
    <?php echo bp_search_form_type_select() ?>
    <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    <?php wp_nonce_field( 'bp_search_form' ) ?>
    </form><!-- #search-form -->
    <?php endif; ?>

    The one you mentioned. But again I had already tried it
    .
    <?php if ( is_user_logged_in() ) : ?>
    <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form"><input type="text" id="search-terms" name="search-terms" value="" size="18"/>
    <?php echo bp_search_form_type_select() ?>
    <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    <?php wp_nonce_field( 'bp_search_form' ) ?>
    </form><!-- #search-form -->
    <?php endif; ?>

    I know it's pretty basic stuff but it did not work though unless you spot something I may have missed. Or can you try a similar setup?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.