Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wp wc php if not is single product page

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' );
Source by wordpress.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #wp #wc #php #single #product #page
ADD COMMENT
Topic
Name
8+9 =