Here is my situation.
I’m using flatsome theme with woocommerce. In its theme customizer, I can just check option boxes to make Account header show “Login / Register” before logging in and show display name (TEST in picture) after logging in. https://imgur.com/7tekdTo https://imgur.com/dYWQg75
These options work correctly on desktop but on mobile website it is not at all. These options don’t apply. I figure my only choice here is JavaScript. But I know next to nothing about HTML and JavaScript. https://imgur.com/p6Tn7Ig https://imgur.com/0i1tCkB
My question here are
- How can I change Login to Login / Register before logging in on mobile.
- How can I make it show display name instead of My Account after logging in on mobile.
I really want to save cost so plug-in isn’t viable option for me. I prefer this default header too because creating custom menu I can’t use popup login / register screen. I have searched online and none of solution work so far.
These are my elements of the mentioned account header.
Before logging in.
<a href="https://www.mywebsite.com/my-account/" class="nav-top-link nav-top-not-logged-in " data-open="#login-form-popup">
<span>
Login / Register </span>
</a>
After logging in.
<a href="https://www.mywebsite.com/my-account/" class="account-link account-login
" title="My account">
<span class="header-account-title">
test </span>
</a>
2
Answers
For now, I found a temporary solution to my first question. I use additional CSS to replace the text.
Where nav-top-link nav-top-not-logged-in is the class of the header before logging in.
Also, I did some digging and I found the files. There are 2 files for this. It appears that the theme use 2 different codes for desktop and mobile. (/wp-content/themes/flatsome/template-parts/header/partials)
There is 1 file called element-account.php.
And there is another file called element-account-mobile.php
@MihaiT is right. Dig around.
Very hard to help with specifics because you’re using a builder, there are so many variables at play in how you have it set up. But all themes use header.php to display whatever is consistent across all headers – notably, login/logout details. You could take a look at your header.php and have a play around with something like this:
You would need to make any changes on a child theme so as not to overwrite any changes you make with a theme update. If you have no intention of ever creating a custom theme, then maybe this approach is not for you, and it’s best to reach out to the theme devs for support. The big problem with themes and builders is the moment you need something that’s not included, you’re in a pickle.
The above code uses a basic if/else and a wordpress function that detects if the user is logged in. Because you’re running this in the back end you have access to useful data such as username. You’d need to figure out the links for logging in/out but this is the general theory.