Hello everyone,,
I am trying to write a role-specific redirect snippet within my Wordpress Child Theme Functions .php file.
Essentially, I want to redirect users to an account login/creation page to prevent them from accessing or seeing the wholesale shop/cart/checkout (page IDs 470, 472, and 478) IF not logged in AND with proper role permissions.
The PHP snippet isn't functioning, and I am getting back " syntax error, unexpected '&&' (T_BOOLEAN_AND)"
Any help spotting or correcting where I am going wrong?
Thank you!
/ Redirect User FROM Cart/Checkout/Shop TO Account IF NOT logged in as a defined user role /
function cm_redirect_users_by_role() {
if ( ! defined( 'DOING_AJAX' ) ) {
$current_user = wp_get_current_user();
$role_name = $current_user->roles[0];
if (('wholesale_customer' || 'admin' || 'shop_manager' ) != $role_name) &&
if (is_page('470' || '472' || '478')) {
wp_redirect( '[redirect link here]' );
} // if $role_name
} // if DOING_AJAX
} // cm_redirect_users_by_role
add_action( 'admin_init', 'cm_redirect_users_by_role' );