Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ariel

    (@arielhr1987)

    Hi @evalast

    Your question is not related with this plugin.
    Its more a woo commerce question/feature you want for your installtion.
    Anyway i am more than glad to help. So the code below should do the trick. Replace “example_role” for your your role

    add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1);
     
    function _wc_disable_admin_bar($prevent_admin_access) {
        if (!current_user_can('example_role')) {
            return $prevent_admin_access;
        }
        return false;
    }
     
    add_filter('woocommerce_prevent_admin_access', '_wc_prevent_admin_access', 10, 1);
     
    function _wc_prevent_admin_access($prevent_admin_access) {
        if (!current_user_can('example_role')) {
            return $prevent_admin_access;
        }
        return false;
    }
    Thread Starter evalast

    (@evalast)

    Thank you Ariel. I will try. In the meantime i cloned a admin role and removed some capabilities to achieve the wanted result. Was this a good idea or should i create a new role with the filters. best

    Plugin Author Ariel

    (@arielhr1987)

    While cloning the admin role is a good idea, i dont think is a good idea to give regular users such kind priviledge. I supose you removed certain capabilities for this cloned role, so regular users shouldnt be able to break anything in theory, but i am not so sure about it.
    My advise leave user roles as they are and use the snippet i sent you.
    Kind Regards

    Thread Starter evalast

    (@evalast)

    Thank you for the quick response – makes sense. Just tested the filters with the subscriber role – works fine. Keep up the great work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocommerce blocks Admin Access – How to allow new user Role to access?’ is closed to new replies.