My guess is that your problem is here:
if (is_product_category('b2b'))
Taking a look at the Woocommerce Documention for Conditional Tags is_product_category()
will return true
on product category archives. Therefore, it will never be true on the single product page.
What I think you need instead is has_term()
which checks a post for a particular term. Therefore I would suggest you change your conditional to:
<?php if (has_term('b2b', 'product_cat')) && if current_user_can('read_b2b') { ?>
Related Posts:
- Is there way to rename user role name without plugin?
- How to create a clone role in wordpress
- How to add a Capability to a User Role?
- How can I get a list of users by their role?
- How do I make a draft post accessible to everyone?
- Reset default roles and capabilities
- add_role() run only once?
- What do unfiltered_html and unfiltered_upload actually filter?
- Temporary capability for current_user_can()
- Allow roles below admin to add subscribers only
- How can I modify the Capability needed to access a plugin’s options?
- Temporarily give ‘manage_options’ capability
- Hide specific admin users’ posts
- WordPress Capabilities: edit_user vs edit_users
- Allow authors to edit only certain users
- How to update role capabilities
- Allowing Custom Capability to Manage Plugin Options
- Do custom user roles have any default capabilities?
- How to programmatically add a user to a role?
- how to add custom user capabilities using add_user_meta or something else?
- Add Capabilities to Custom Post Type after it has been created [duplicate]
- Allow user to Publish, but not Edit or Delete
- Email notification for editors only
- Shold I manually add ‘cap’ to admin role ?
- Allow users to publish child pages of the pages they have access to edit
- New Roles and Capabilities in WordPress
- Why is wp-login redirecting to the home page when I use this function?
- Allow contributor to view own scheduled post
- How to prevent users with “edit_others_posts” capability from editing admin posts
- Author Role – Allow editing of Gallery images
- What is the difference between “create_users” and “add_users” capabilities?
- How to get all users with Author role capabilities?
- How to check if a role has a specific capability
- Locking Down WordPress Application Password Permissions / Capabilities
- Prevent custom user role to add new pages
- Allow user to edit specific user with meta key using map_meta_cap
- How to remove sticky post capability for a specific user role?
- Let new user role to ‘edit_others_posts’ of other user role, not of its own type
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- The delete_posts capability?
- How to restrict access to specific pages on the back-end?
- Capabilites not working [closed]
- add_menu_page() for more than one user role
- Remove wordpress author’s capability to moderate comments on their own posts
- Update User Role
- Can you set a role as author?
- Prevent Editors from Editing/Deleting Admin Accounts
- Where are the WordPress capabilities stored?
- Adding Capabilities to a WordPress User Account
- Adding an additional role to an Administrator
- Custom user roles for access to specific parts of the site
- Pending status by default for a specific role
- How do I restrict user access to plugins?
- My subscriber has the “edit comment” capability but can’t edit comment
- Show metabox for a special role
- User Role Capabilities for WordPress Gutenberg Blocks
- Subscriber (with read permissions) cannot view Private posts
- How can I add a custom role capability to use in a custom plugin?
- bbPress plugin moderator roles
- Allowing user to edit posts based on the post status
- Custom capabilities to add, edit, remove users of a particular role only?
- Stop users of author role from editing already pending posts
- add_role user capability not working
- Purpose of Adding Capability to Role But Not Grant?
- How can I promote a user to a network administrator?
- Reset Roles (or undo role changes on theme change)
- How to get a users list by who created them?
- Authorize users for specific pages and/or categories
- Custom Capabilities for CPT and Problem with current_user_can()
- Custom wordpress admin page/url “You do not have sufficient permissions to access this page.”
- Hiding custom theme functionality using capabilities
- user_can() not working for comment authors
- Which capabilities are available in Gravity Forms Salesforce plugin? [closed]
- How to write conditions based on user capabilities not on user role?
- What Capability is required to let a role RUN code in Edit Theme?
- Want to know parameters that can be passed to user_can() for access control by user capabilities
- Create sub-administrator role that can do everything except use or see the code editor
- Let editors view post in admin but not be able to perform a save/edit
- Capabilities don’t add
- Remove specific administrator’s capability
- How To Create A File Archive in WordPress?
- How to hide plugin options for editors via functions.php
- User role editor – Add download files capability
- Adding plugin editing capability for Author
- Why can my subscribers create new posts for review?
- Disabled delete_others_posts if post is from admin
- How can I check if a visitor can read a post?
- How to query users to count all with a custom capability and limit it to a set of roles?
- Adding all custom capabilities to admin
- See which user role / capability is needed to use a plugin
- Want to add post to user dashboard
- Sync roles across several plugins
- How to disable plugin capability : “create new category”
- edit slider plugin capability for custom_role
- How might I enable a user to view Draft pages from a different Author, without the ability to edit?
- How can I display customizer’s “Additional CSS” to administrators and editors (in multisite)?
- coauthors_plus_edit_authors to display metabox based on author caps
- Why is user_can_access_admin_page() an undefined function?
- Easiest way to create Reviewer Role: Can preview Drafts (and Private Pages) but not Edit them
- How can I add the User Menu for Authors (role)?