It’s once again WooCommerce customization time! As in the past 2 episodes (open external product in new tab and show shipping rates @ single product), I’m featuring snippets and code I personally use on my Sicilian marketplace/dropshipping business called A Piece of Sicily.
Today, I’ll quickly show you how to personalize the default WordPress login/logged out page with your custom logo and link as opposed to showing the WordPress logo and the wordpress.org image link, which to be completely honest, shouldn’t be there in the first place!
So, enjoy! You can see the live result here: https://www.apieceofsicily.com/en/login/?loggedout=true
Continue reading WordPress: Custom Logo @ WP Login Page
We’ve already seen how to set a custom My Account login redirect URL by user role – but today we want to cover another case scenario: redirecting users to the previous URL (referrer) after logging in from the My Account page.
Actually, WooCommerce already prints a hidden input field (“_wp_http_referer“) in the login form thanks to wp_nonce_field(), but for some reason this is not enough to allow the actual redirect.
Thankfully, the WooCommerce process_login() function provides another workaround: if $_POST[‘redirect’] is set, the form will consider redirecting to this URL instead of the default My Account Dashboard! This means we can simply add a new hidden field to the login form with that exact name (“redirect”), so that we can make that function trigger the redirect we want.
Easier coded than said, so let’s see how it’s done. Enjoy!
Continue reading WooCommerce: Login Redirect to Previous URL @ My Account
There are times when you don’t want customers to login and be redirected to the default “My Account” dashboard. Maybe because you have a membership site and you want them to go to a custom “Welcome” page, or maybe you wish to send them straight to their “My Account” > “Downloads” subsection.
No matter the why, for sure figuring out how to achieve a custom redirect once a user logs in from the “My Account” page is quite straightforward. The hook we’ll use is called “woocommerce_login_redirect” and allows us to trigger a safe redirect whenever a customer clicks on the LOGIN button. Enjoy!
Continue reading WooCommerce: Login Redirect by User Role @ My Account
There are times when you need to send logged out customers to a Login page and unregistered customers to a distinct Register page.
As you know, the WooCommerce My Account page, which contains the [woocommerce_my_account] shortcode, has both Login and Registration forms. But this is not always a good idea, mostly when you use landing pages or sales pages with a specific goal e.g. user registration.
Clearly, when this happens, you don’t want to have a login form there as well. My solution provides two new shortcodes, one for the login form and one for the register form.
Please be aware both shortcodes’ content is copied from WooCommerce template files – if WooCommerce releases an update or makes a change to these files, you need to change the shortcode coding too.
Give it a go, feedback is much appreciated 🙂
Continue reading WooCommerce: Separate Login and Registration Pages