Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
866 B
1
Indexable
Never
add_filter('salesking_agents_see_all_orders','__return_true');
add_filter( 'user_has_cap', 'grant_edit_shop_order_capability', 100, 3 );

function grant_edit_shop_order_capability( $allcaps, $cap, $args ) {
	$user_id = get_current_user_id();
	
	$agent_group = get_user_meta($user_id,'salesking_group',true);
	if ($agent_group !== 'none' && !empty($agent_group) && $_GET['page']==='wc-orders'){
	//	var_dump($cap[0]);
		$allcaps[ $cap[0] ] = true;
		$allcaps['manage_woocommerce'] = false;
		$allcaps['view_woocommerce_reports'] = false;
		$allcaps['manage_options'] = false;
		$allcaps['activate_plugins'] = false;
		$allcaps['manage_plugins'] = false;
		$allcaps['install_plugins'] = false;
		$allcaps['update_plugins'] = false;
		$allcaps['list_users'] = false;
		$allcaps['create_users'] = false;
		$allcaps['delete_users'] = false;
	}
	

    return $allcaps;
}

Leave a Comment