Skip to content
Advertisement

How to hide the storefront search box for not logged users?

On woocommerce storefront header, I want to hide the search box for not-logged users, and replace it with 2 yellow buttons: “Login”, “Register” (like the stackoverflow landing-page header) that send to my customized login/register urls. I tried this CSS code that works to hide the search box, but I don’t know what to do next:

JavaScript

Advertisement

Answer

You can use the following that will add a body class when users are not logged in as follow:

JavaScript

Code goes in functions.php file of the active child theme (or active theme).

Then you can use the following CSS rule to hide the storefront search box for non logged users:

JavaScript

Tested and works.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement