#3335
Vladimir
Keymaster

It seems that you use an older version of Woocommerce. If we look at the latest one, this code looks like:


public function prevent_admin_access() {
		$prevent_access = false;

		if ( 'yes' === get_option( 'woocommerce_lock_down_admin', 'yes' ) && ! is_ajax() && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) {
			$has_cap     = false;
			$access_caps = array( 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' );

			foreach ( $access_caps as $access_cap ) {
				if ( current_user_can( $access_cap ) ) {
					$has_cap = true;
					break;
				}
			}

			if ( ! $has_cap ) {
				$prevent_access = true;
			}
		}

		if ( apply_filters( 'woocommerce_prevent_admin_access', $prevent_access ) ) {
			wp_safe_redirect( wc_get_page_permalink( 'myaccount' ) );
			exit;
		}
	}

You can see that ‘view_admin_dashboard’ was added. This could be the reason why this capability did not work for you. Custom code to add WooCommerce’s ‘woocommerce_prevent_admin_access’ filter is not needed with it. So, in hope that the most of clients use the latest version of WooCommerce, there is no need to add such code to the User Role Editor.