• Resolved anatsia

    (@anatsia)


    Hi,
    is it possible to show search box only if user is logged in? i’m using Storefront child theme.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Damian Góra

    (@damian-gora)

    Hi there,

    Of course, you can do it. Paste the following code in your child theme (functions.php file) or use the Code Snippets plugin.

    
    /**
     * Show search box only if user is logged in
     *
     * @param string $output The output from the shortcode
     * @param string $tag The name of the shortcode
     *
     * @return string The modified output
     */
    add_filter('do_shortcode_tag', function ($output, $tag) {
        if ('wcas-search-form' === $tag && !is_user_logged_in()) {
            $output = '';
        }
        return $output;
    }, 10, 2);
    

    Best Regards
    Damian Góra

    Thread Starter anatsia

    (@anatsia)

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable / remove search box’ is closed to new replies.