Redirect to Dashboard after login with WooCommerce enabled

Recently, I had to work on a site that had a few things going on:

  1. It had some users with custom roles, and capabilities
  2. Those users had a simplified dashboard
  3. WooCommerce was enabled.

The problem was that when those users logged in, WooCommerce would redirect them to the “My Account” page, instead of their simplified dashboard.

I found a lot of places where they showed how to redirect users after login to “any” page, but it didn’t seem to work when the dashboard was that page.

After some digging around, I discovered that WooCommerce also redirects users that try to access the Dashboard directly to “My Account”.

So, if you are ever in this situation you need to do two things:

  1. Redirect the login (and registration) to the Dashboard
  2. Allow them to access the Dashboard

Here’s the code (change “custom_role” to your users’ role):

Hope this helps someone.

4 Responses to “Redirect to Dashboard after login with WooCommerce enabled”

  1. Babusiaux Guillaume

    Hey,

    i’m trying to make this code work..
    Should i replace mytheme_ by the name of my theme? sorry i’m really noob with coding
    Thanks

    Reply
  2. Tom

    Hello and thank you for your post. I just tried using this code to resolve this same issue at my WordPress site. I could not get it to work. Am I correct in assuming this should go into the functions.php file of my theme?

    Reply
    • Alicia Ramirez

      Yes, it goes into functions.php. Please try again, I just spotted and fixed a typo on line 3. Also, make sure to change ‘custom_role’ on lines 3 and 17 to the name of the role you want to make the dashboard available to. Hopefully, that will fix it, but keep in mind that I posted this in March, so things may have changed on WooCommerce since then.

      Reply

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">