Jump to content

Field not returning when not logged in...


a-ok
 Share

Recommended Posts

I'm having a bit of a weird issue.

I have a pageReferenceField on a couple of different templates (it's the same field) and under two of the templates it seems to work fine but under one of the templates the field will only return when I'm logged in.

I have tested this with a few things (different browsers) and when checking the count it shows int(1) when logged in but int(0) on the other browser/incognito mode (not logged in). I then tested the viewability of the field with $page->viewable('field_name'); and on both logged in and logged out states they return bool(true) which made me even more confused.

Is there anything I can be checking? I use ProCache on the site but I've turned it off locally for these tests.

Link to comment
Share on other sites

5 minutes ago, wbmnfktr said:

I'm out of ideas by now. Everything else would be guessing.

I'd double check everything. Templates, fields, pages, referenced pages, queries.

 

I stuck the same test on the other template (count of the field and $page->viewable('field_name')) and the count is returned when logged out but on the other template it's not. I've checked all templates, fields, page etc. It's the same field on both templates.

Is there a way to check a field access via API?

Link to comment
Share on other sites

30 minutes ago, oma said:

Is there a way to check a field access via API?

I don't know but I guess there are ways to check it via API.

If it's the same field as in other templates and if there are no permissions set for that field there must be another problem.

Right now without knowing anything about templates, fields, references, or queries I'm out.

Link to comment
Share on other sites

16 hours ago, oma said:

Is there a way to check a field access via API?

Yes

$field = 'pass'; // field to check
$template = 'user'; // context template

$myField = $fields->get($field);
$contextTemplate = $templates->get($template)->fieldgroup;
$myFieldInContext = $contextTemplate->getFieldContext($myField);

$case = $myField->viewable()? '' : ' not'; // optional arguments: 1 = page, 2 = user
$message = "Field $field is$case viewable.";

if (!$contextTemplate->has($myField)) $message .= " Field $field is not part of template $template.";
else {
	$case = $myFieldInContext->viewable()? '' : ' not'; // optional arguments: 1 = page, 2 = user
	$message .= " Field $field is$case viewable in context with template $template.";
}
var_dump($message);

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...