- Issue created by @problue solutions
- πΊπΈUnited States partdigital
I would need to see what settings you set for your access policy and permissions. However, make sure that the roles have the "Assign access policy" permission and that "First available" is selected under default policy. Otherwise it won't assign an access policy. This functionality has test coverage so it should all be working as expected.
Feel free to reach out on Slack if you have any questions.
- Status changed to Postponed: needs info
8 months ago 8:13pm 24 April 2024 - π¬π§United Kingdom problue solutions Northern Ireland
Hi, thanks for following up.
Unfortunately no I was unable to figure it out.
I started again and carefully followed the tutorial to ensure I hadn't missed anything but I got the same result, the widget still defaults to "- Unrestricted -", with "Me only" available to select.
I thought maybe its something to do with it being a custom entity so I created the policy again for the node entity type but got the same result as above.
I am testing with just the administrator account so I have required permissions.
- πΊπΈUnited States partdigital
Would you be willing to share an export of your access policy?
- π¬π§United Kingdom problue solutions Northern Ireland
langcode: en-gb status: true dependencies: { } id: me_only label: 'Me only' description: 'Only you and the users below have access to this content.' weight: 0 access_rules: is_own: id: is_own group: ccs_entity plugin_id: is_own field: uid entity_type: ccs_entity settings: admin_label: '' query: true required: false field_grant_access_to_users_user_reference: id: field_grant_access_to_users_user_reference group: ccs_entity plugin_id: entity_field_standard field: field_grant_access_to_users entity_type: ccs_entity settings: admin_label: '' query: true operator: '=' value: field: uid empty_behavior: deny widget: show: 1 settings: field_widget: entity_reference_autocomplete hide_original_field: 1 operations: - view required: false access_rule_operator: OR query: true target_entity_type_id: ccs_entity operations: view_unpublished: permission: false access_rules: true show_column: true view: permission: false access_rules: true show_column: true view_all_revisions: permission: false access_rules: true show_column: true edit: permission: false access_rules: true show_column: true delete: permission: false access_rules: true show_column: true manage_access: permission: true access_rules: true show_column: true type: group http_403_response: { } selection_rules: is_own: id: is_own group: ccs_entity plugin_id: is_own field: uid entity_type: ccs_entity settings: id: 'ccs_entity:is_own' admin_label: '' required: false selection_rule_operator: AND selection_set: { }
- πΊπΈUnited States partdigital
Thanks for sharing. I noticed that the language is set to en-gb, is that the default language? The "First available" setting will only work for content created in the default language.
You can check that setting here: /admin/config/regional/language
You can see more details here: https://www.drupal.org/project/access_policy/issues/3438598 π Access policy updates get ignored when not using default language Active
If you have multiple policies, another issue that I've occasionally run into is when the weights of all the access policies are set to 0, sometimes their assignment doesn't behave predictably (still under investigation).
As a quick workaround you can:
- Go to /admin/people/access-policies/node/settings
- Sort the access policies by dragging the handles (it doesn't matter which order).
- Click save
- Go back to /admin/people/access-policies/node/settings
- Sort the access policies in the order that you want.
- Click save, this should properly set the weight on the policies.
- π¬π§United Kingdom problue solutions Northern Ireland
Thanks for having a look.
I didn't have the language module installed, so I installed it and added English, British (en-gb) and set it to default and cleared cache.
I added a new entity and tried again but unfortunately the same behavior as before, widget defaults to Unrestricted.
I did have other policies as I was testing both node entities and custom entities, so i deleted all policies except one and tried again, but unfortunately this didnt work either, the widget still defaults to Unrestricted.
As i mentioned before, I also tried turning off "Allow empty" - "Allow authors to create and edit ccs entities without an access policy."
I'm not sure what this is supposed to do as it does not prevent creating or editing entities when "- Unrestricted -" is selected in the widget. I tried turning off "Hide original field widget" in the access rule because if "Allow empty" being turned off works as described, I dont see how the entity could be created without setting the access policy before saving, but this made no difference and allowed me to go ahead and save the entity with "Set access to: Unrestricted" still selected when viewing the Access tab.
Maybe this setting doesnt work as intended due to my orginal issue?
Thank you again for taking the time to respond.
- πΊπΈUnited States partdigital
Hi Problue Solutions,
It's going to be a guessing game until I'm able to reproduce it. Are you able to determine at which point in the code the functionality is not working? For example as part of
access_policy_entity_presave()
? Are you available to connect on Slack? It think it will be easier to diagnose this in real time. - π¬π§United Kingdom problue solutions Northern Ireland
Hi,
Just confiming I did get this to work as descibed on a different site, I've no idea what modules or configuration may have been causing the issue on the other site and didnt have time to continue trying to work it out unfortunately.