Here is the result that works, I put in the condition : is_product()
to check if is a single product page.
And I changed in the add_action()
: admin_init by wp
function cm_redirect_users_by_role() {
$current_user = wp_get_current_user();
$role_name = $current_user->roles[0];
if ( is_product() ){
if ( $role_name !== 'customer' && $role_name !== 'shop_manager' && $role_name !== 'dc_vendor') {
wp_redirect( 'https://www.mysite.fr/' );
} // if
}
} // cm_redirect_users_by_role
add_action( 'wp', 'cm_redirect_users_by_role' );
Related Posts:
- Restrict admin access to certain pages for certain users
- How to redirect on particular page in wordpress? [closed]
- Where does the 404 redirection happen?
- Show different badge based upon the user role
- How to change redirect after moving a page to trash?
- Password Protected Page Not Displaying Content After Entering Password
- User capability of create page/new page
- Redirect “Sorry, you are not allowed to access this page.” to Home
- How to redirect a page to subdomain?
- Slug is redirecting to 404
- remove/hide pages from users backend
- If a page does not exist, include a different page?
- List all private pages user has access rights to read
- How to redirect a page to another?
- Page redirects to archive
- Restricting Pages based on Hierarchy and User Role
- Unique page URL redirect to file_get_contents() at domain
- Change base URL of pages created by certain users
- Role can edit just one page [closed]
- Redirect page to default subpage
- How do we exclude multiple pages (like opposite of is_page)
- Page access only from a specific page in wordpress website
- logout redirect only from admin page
- WordPress page not taking precedence over server directory
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- Folder wordpress page redirect
- How to rewrite a page url
- Allow a user to edit their own page and profile only
- redirect index.html inside folder to wordpress page of same name
- is_single(); Question
- wp_query issue with post_type = page
- Custom page only editable by one user
- One author not showing in Author drop down list while editing page
- How should I set up a Tumblr blog at a WordPress Page?
- Different template parts when on different pages
- Every change made by “Author” role is going to “pending review”
- URL redirect to home page issue in word press site
- WordPress redirects to login page when I enter url.com/index.php
- Not allow add New Page for role ‘editor’
- Cannot use old slug – it just 301s to site home page
- Make wordpress pages accessible for Woocommerce logged in users only
- How to limit the pages shown in the page manager to those created by the logged in user?
- Is it better to set social media sharer in entry-footer.php or comments.php in WordPress blog?
- Add role and edit page capabilities
- different single.php for different page templates
- disable trashability for certain pages
- Parent for a single (single.php)
- How to change the default location where new post gets stored?
- How to configure WordPress to handle 75,000 pages?
- Allow only new sub-pages to be created
- Set page template automatically based on parent
- What is the use of $page_title and how to use it?
- Set Session Time Limit for Password Protected Posts
- Remember page before login page, redirect to that page after login
- Is there a way to stop WP editor deleting
- How do I redirect upon login a specific user based on role?
- Add new page with preselected parent
- When I split a large post with , how can a search locate users to the correct page?
- Child page from 2 different parent pages
- Redirect after users complete profile form
- How-to Change Content with location change?
- How can I automatically add child pages to pages in a WP menu?
- Job Manager plugin help?
- How get get list of pages in ajax search
- How to Move My Page into WordPress dashboard main menu
- Do the permalink settings apply to pages as well as posts?
- Can I allow certain people to add/edit pages within a parent?
- check first and last child pages wordpress
- Special Character Appearing in my WordPress Pages Content
- Prioritize visible content – Page speed issue on Google insights
- How can I check user capability when a page loads (via functions.php)?
- Bad pages redirection
- Password Protect Pages Not Working
- Can I connect a page to a taxonomy?
- wp_nav_menu: output featured image of each page listing
- Creating a redirect option for current page url
- Change displayed “page name” to distinguish multiple pages with the same title
- How to transfer a site to hosting?
- Add the same content to multiple pages
- WooThemes – Vendors / Bookings – Allow Vendors to manage resources
- Front Page post mirroring revisions to other pages, constantly updating itself
- Conditional redirect on login using referring URL
- Changing second user role while updating/downgrading membership level – s2member [closed]
- Adding my own custom template page but got white page
- Display inner pages like posts.[Like how post excerpt works]
- include exception inside theme for empty widget area
- Add text to the bottom of particular pages
- Access wordpress pages using a self signed shared ssl
- Page loads all pages of the image gallery with pagination
- How to exclude page in pages module
- get id custom tables on current page
- Multiple WordPress Pages
- How to create an user defined page?
- I have over 3000 child pages – but I need a different main page
- How to enable automatic search results in WordPress
- How to make a conditional statement that checks if the page is the child of a certain page?
- Missing page on wordpress “Pages” dashboard [closed]
- How to customize the author page in wordpress?
- User profile in front-end
- custom css in one page