Creating a new user as admin resets admins priavacy settings

Created on 7 March 2024, 10 months ago

Problem/Motivation

Inside the admin interface add a new user and set some private fields. As this user doesn't yet exists in database (no user_id yet), the admins uid is used when saving the new user.

Steps to reproduce

  1. Log in as admin
  2. Enable privacy to some user fields (config/people/accounts)
  3. Set privacy values to the admins profile for those fields (they should be different for easiest comparison, see below)
  4. Check database table user_private_fields_value and note the values
  5. Create a new user and set the same value to the same fields you set in admin's profile.
  6. Check back admins profile. All concerned fields have the privacy settings of the new user.
  7. Check the new user's profile. all concerned fields are public
  8. Check database table. It confirms the above for admin and there are no records for the new user.

Proposed resolution

This module looks like a fork of User field privacy . They deal the problem with drupal_static function. Here is a comment from their code:

//Don't panic: here comes drupal_static() and hook_exit() to the help. Let's store the state
// of all the user's checkboxes into a drupal_static() along with her
// {users}.mail (which we DO have here, too), and write our own precious
// data to the DB in hook_exit().

But this code is old and needs to be refactored.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France erwangel

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

Comments & Activities

Production build 0.71.5 2024