I set up an entire template group to be accessible by a specific user group and to redirect other users to a page on the site.
The users member of the group can visit the page just fine, but when I try to access the page with a user not within the allowed group the user is not redirected correctly and it’s shown a page.
I tried everything on the templates and settings on the CP and finally I decided to take a crack at the template source code.
It looks the bounce template is hardcoded to a numeric id: 3 in template.php lines 2189 .
Please check the line under the comment starting with FRAM.
// Is the current user allowed to view this template?
if ($query->row('enable_http_auth') != 'y' && $query->row('no_auth_bounce') != '')
{
$this->log_item("Determining Template Access Privileges");
$this->EE->db->select('COUNT(*) as count');
$this->EE->db->where('template_id', $query->row('template_id'));
$this->EE->db->where('member_group', $this->EE->session->userdata('group_id'));
$result = $this->EE->db->get('template_no_access');
if ($result->row('count') > 0)
{
if ($this->depth > 0)
{
return '';
}
$query = $this->EE->db->select('a.template_id, a.template_data,
a.template_name, a.template_type, a.edit_date,
a.save_template_file, a.cache, a.refresh, a.hits,
a.allow_php, a.php_parse_location, b.group_name')
->from('templates a')
->join('template_groups b', 'a.group_id = b.group_id')
// FRAM Comment this looks quite wrong ...
->where('template_id', 3)
->get();
}
}Shouldn’t that value set to $query->row(‘no_auth_bounce’) changing the query code fixes my problem:
$query = $this->EE->db->select('a.template_id, a.template_data,
a.template_name, a.template_type, a.edit_date,
a.save_template_file, a.cache, a.refresh, a.hits,
a.allow_php, a.php_parse_location, b.group_name')
->from('templates a')
->join('template_groups b', 'a.group_id = b.group_id')
// FRAM Comment is the following code correct ?
->where('template_id', $query->row('no_auth_bounce'))
->get();Please let me know what you think.
FraM