Customer ID 2 can see Product ID 22 which is linked to Category ID 13 and 32.

Product Listing returns the master_categories_id as 32 for all customers.

Customer access restriction is working properly - if you link a product to a restricted category, the product shows to the correct customer.

However when it shows up, the link is incorrect.

I need it to return the link with the master_category_id relative to the category it's linked in.

In the database product_to_categories looks like this:
Product ID 22 Category ID 32
Product ID 22 Category ID 13

Which will always return the master category of 32.

I need it to see that the product is actually in category 13.

Note: Changing the master category will allow Customer ID 2 to see the correct link - master category 13, but all other restricted customers will see the incorrect master category 32 link.

includes/modules/product_listing.php - line 151
This is the output code:
PHP Code:
        $lc_text '<h4 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '</a></h4><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>'
zen_get_generated_category_path_rev($listing->fields['master_categories_id'])

This is the function that always returns the master category:
includes/functions/functions_categories.php
PHP Code:
  function zen_get_generated_category_path_rev($this_categories_id) {
    
$categories = array();
    
zen_get_parent_categories($categories$this_categories_id);

    
$categories array_reverse($categories);

    
$categories_imploded implode('_'$categories);

    if (
zen_not_null($categories_imploded)) $categories_imploded .= '_';
    
$categories_imploded .= $this_categories_id;

    return 
$categories_imploded;
  } 

Help is appreciated :)