Correct way to assert user can read product?
-
I’m using the following code to assert user can read a product:
$pto = get_post_type_object('product'); return current_user_can($pto->cap->read_post, $product->get_id());
However, this does not work for guests. I have tried
$pto->cap->read
as well.I was using
\WC_Product::is_visible()
before, but I was told it was a security breach.What is the correct way of asserting a user can read a product in WooCommerce?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Correct way to assert user can read product?’ is closed to new replies.