4

I am in a deep trouble. Please help me to find a solution for the following.

I have wordpress site which uses Woocommerce Plugin. Normally Woocommerce doesn't allow normal Users (Customer,User - These are roles that you can Select from Wordpress Admin Area > Add new User > Role). The problem is that only Administrator(Role) privilege guys have the access to see the Admin area dashboard and full settings.

I need all users to enter into dashboard area without redirecting to my-account page . Because now when users with Role Customer or something like, tried to enter login credentials of admin, they are getting redirected to my-account page. Only Administrator privilege role has the capability of entering the dashboard and settings.

So I searched in google and found the following link:

WooCommerce admin bar and dashboard access - Role editor page link

I tried the following link by writing the following code in functions.php , but now I can't see admin settings, please see the screenshot that I can see when entering as a normal user.

Normal User Login

I need all users access to see admin area dashboard and admin area settings (able to see Post, Page, Settings etc) and donot want to redirect to my-account page.

please help to find a solution for this, since I am struggling with this for a long time.

Micho
  • 3,740
  • 13
  • 33
  • 39

3 Answers3

3

I spent a lot of time looking for the answer to this one and it can be found in the class-wc-admin.php file under the prevent_admin_access function.

Add the following code:

add_filter( 'woocommerce_prevent_admin_access', '__return_false' );

To your functions PHP file and it will stop it blocking users who do not have: 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' from accessing the dashboard.

For good measure you can also add this which overrides the account permalink to be your admin page - which may be relevant.

function my_account_permalink($permalink) {

    return admin_url();
}

add_filter( 'woocommerce_get_myaccount_page_permalink', 'my_account_permalink', 1); 
LauraTheExplorer
  • 722
  • 8
  • 21
1

As LauraTheExplorer said, use this filter:

add_filter( 'woocommerce_prevent_admin_access', '__return_false' );

Use this filter to also enable the Admin Bar:

add_filter('woocommerce_disable_admin_bar', '__return_false');

sMyles
  • 1,808
  • 1
  • 23
  • 38
0

There might be another plugin redirecting a user to the WooCommerce, My Account Page.

In the case of the Formidable Forms plug in along with the Formidable Registration plug in, this can happen if the Login/Logout Page is set to the My Account Page. This setting can be found at Formidable, Global Settings, Registration and under Global Pages change the Login/Logout - click the drop list and scroll to the blank line at the top of this list.

However in your case you might have a different plug in doing something similar.