While I'm developing a website and doing some testing I would like to block access to non-admin (and eventually non-editors) to specific pages such as the woocommerce shop and related pages.
Is there a way, without using plugins, in the functions.php
to check:
$list_of_blocked_pages = [ 'shop', 'cart', 'checkout', 'etc...' ];
if ( current_page_is_in( $list_of_blocked_pages ) && !admin && !editor ) {
redirect_to_page( $url );
}
hook
to use in thefunctions.php
file? Essentially I would like to know what is the right and clean way to do that.woocommerce
androuting
as these are key points in answering this questions? Woocommerce pages cannot be "password protected" or made "private" through the page's publishing options. This issue might have also been solved on therouting
level I guess. Your clarification could help me in being more precise and correct next time.