Don't display search form for logged out visitors

// This example shows you how not to display the search form for logged out
// visitors using the bp-default theme. It uses a combination of php and CSS. Adjust it accordingly
    <?php
    // Prevent logged out users from accessing the search form 
    function bphelp_remove_searchform_for_logged_out_visitors() {
            if ( ! is_user_logged_in() ) {
    ?>
            <style type="text/css">
                    form#search-form {
                            display: none;
            }

        </style>
    <?php

            }

    }
    add_action ('bp_head', 'bphelp_remove_searchform_for_logged_out_visitors');
    ?>

#conditionals,css,php