<?php
// the code below goes in your theme's functions.php file
function my_custom_pos_template_redirect() {
// a manual map of Store IDs => array of User IDs
$restrict = array(
1524 => array( 52, 863 ), // ie: Store ID 1524 restricted to User IDs 52 and 863
6252 => array( 863 ) // ie: Store ID 6252 restricted to User ID 863
);
// get current User ID & logged in Store ID
$user_id = get_current_user_id();
$store_id = get_user_option('woocommerce_pos_store');
// check User ID array exists and User ID in array, if not, display error
if( ! isset( $restrict[$store_id] ) || ! in_array( $user_id, $restrict[$store_id] ) ) {
wp_die( 'You do not have sufficient permissions to access this store.' );
}
}
// woocommerce_pos_template_redirect runs just before the POS template is rendered
add_action( 'woocommerce_pos_template_redirect', 'my_custom_pos_template_redirect', 20 );