Compatibility with Multiple Registration module

Created on 12 May 2023, almost 2 years ago
Updated 6 January 2024, over 1 year ago

Problem/Motivation

Custom permissions assigned to custom fields created on user accounts are not respected.

This is not the first time I am encountering this issue. Some years ago I had a site where we wanted to stop users from seeing and editing certain fields on their profile and we wanted to use those fields for admin purposes. We set the permissions and took it for granted they were working only to discover later that the users were well seeing the fields and could edit them as they pleased.

Steps to reproduce

Add a field to a user account and set custom permissions for the user (owner of field) not to be able to view nor edit the field nor anyone else apart from an admin. Login as the user and you would see you can well see the field and edit it.

πŸ› Bug report
Status

Closed: duplicate

Version

1.2

Component

Code

Created by

πŸ‡³πŸ‡¬Nigeria chike Nigeria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @chike
  • πŸ‡ΈπŸ‡°Slovakia coaston

    Hello chike,

    I am unable to reproduce the issue.

    1.Go to /admin/config/people/accounts/fields
    2.Add new filed like Country (free text field or entity refrenrece to taxonomy)
    3.edit field Country > Field visibility and permissions > Custom permissions > and do not select anything, keep just admin populated everything.
    4.Now login as user
    5.I cannot see or edit Country.

    Do you have any other case ?

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    I added a telephone number, phone_number field to users and wants users of role 'Agent' to be able to create the field but not be able to edit it after saving it.

    I set the permissions as this,

    But when I log in as 'Agent' I am still able to edit the phone_number field.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    I just tested for D9 and D10 and it works for me.

    1. Created new role
    2. Added all permissions to role for a new user create
    3. Added country field to user profile and set permission to create and view own
    4. Logged as user with a new role
    5. Created new user - was able to add country
    6. If i click edit user i cannot see country, hence cannot update it.

    However in drupal 9 i can see field country but it is greyed out so unable to update it. In drupal 10 i am unable to see that field which is odd. But yeah as i cannot see i cannot update.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    Could you try with a telephone field?

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    I have found the cause. I am using Multiple Registration module, https://www.drupal.org/project/multiple_registration β†’ and incidentally I used it in every site I had this issue with field_permissions. Multiple Registration adds it's own visibility permissions for fields like,

    Once I check any box there that includes the role, it disables 'field_permissions' for that field for that role.

    So now when I removed the checkmarks, the phone_number field became hidden and I wasn't able to see it on the edit form meaning I couldn't edit it. Using Drupal 10.

    I think the behaviour in Drupal 9 is preferable being that one should see the field grayed out.

    Thank you.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    I can confirm this bug. If you use Multiple Registration module, Field Permissions rules are ignored.

  • Status changed to Closed: duplicate over 1 year ago
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    @chike: The problem is with Multiple Registration. I found another issue πŸ› Editing profile does not respect field permissions Needs review , with a patch which solves the problem for me. Maybe you can try it, and see if it works for you as well?

    I also don't see the field greyed out, the field is not shown at all. But maybe it's actually best that way? See #3094098-27: Provide form display formatter for greying-out a field or hiding it completely β†’ .

Production build 0.71.5 2024