Questions tagged [users]
Use it for question about the user entity. Don't use it for a generic question about, for example, what users can do on a site.
6,529
questions
0
votes
0
answers
33
views
Drupal 10 - Get the value of a custom user field
i spent my day on that... how to, in Drupal 10, get the value of a custom field added in the user profile.
i read and test everything found on google, just like that (from different thread/forum):
$...
1
vote
2
answers
38
views
Permissions to edit user field data, but not fields itself
How to allow a role to edit/manage user accounts e.g. click Edit and change email, username, password etc., but do not edit the fields itself, e.g. cannot just go to Manage fields and delete/create/...
0
votes
1
answer
73
views
order of role and status on user edit page has changed with 9.5 upgrade
in our 9.3 drupal installation , on the user edit page, the role was before the status. now in 9.5 , the status is above the role. I would like the role to be on top of the status the way it was ...
-2
votes
1
answer
87
views
Constantly creating new Anonymous users
I find that my instance of drupal is always "creating" new anonymous users.
I have an even on Create New User that simply logs the name to a file, and it is filled with entries like
2023-10-...
1
vote
1
answer
122
views
How to make the “last access time” field visible to anonymous users?
I have configured the user data display to show the last access information, but only me as I have the admin role can see it, anonymous users can not, nor even authenticated users:
So my question is ...
0
votes
0
answers
35
views
Deny access to pages or nodes base from a database table
I was modifying a 2fa module for restricting users to access other account's page (user/%/2fa) which is working.
function custom_2fa_menu() {
$items['user/%/2fa'] = [
'title' => t('...
0
votes
0
answers
28
views
Show user fields on user page if user has flagged the viewer
I am stuck with a specific problem with flags and users and views.
I have a flag on the user entity. Users can flag each other. Everything happens in logged in mode.
Every user has some private fields ...
0
votes
2
answers
58
views
Creating user programmatically fails with Postgres
Anyone know what's wrong here? After the D8->D9 upgrade, a stupidly simple piece of code is not working, has there been a change? It worked before.
$params = [
'name' => $username,
'pass' =&...
-2
votes
1
answer
62
views
How do I make an activation link on registration expire in 15 minutes?
I have user registration and forgot password mails sent to the user.
I want 5 minute expiration for forgot password and user registration. Now the forgot password will expire after 5 minutes but new ...
1
vote
1
answer
137
views
Migrate user roles with static_map
I am trying to migrate D7 users into D10.
I have enabled the following migrate modules:
migrate
migrate drupal
migrate plus
migrate tools
The migration yml is as follows:
id: create_user_account
...
0
votes
1
answer
162
views
Programmatically saving data in a field under user account
QR codes have been printed out for a bunch of students in a university.
When they visit the site via those QR codes, and they are logged-in, the refcode query parameter used in the link needs to be ...
1
vote
1
answer
121
views
Get the value of taxonomy custom user field
I am trying to get a taxonomy field in hook_user_insert().
The logic is that if the taxonomy field is selected as none then print warning message along with a success message.
function ...
0
votes
1
answer
53
views
How to inspect the form values in hook_user_update()?
In Drupal 7, one could have the following hook_user_update() to
return TRUE if the 'roles' has been edited:
function example_user_update(&$edit, $account, $category) {
isset($edit['roles']) ? ...
0
votes
0
answers
37
views
People view showing some users multiple times and others not at all
I'm seeing some weird behavior in the build-in People view and I'm going to try to explain it.
There are 168 users in my site. If I change the view to show them all (and not paginate), it shows them ...
-2
votes
1
answer
95
views
Using Webform Submission, update a custom field attached to a user
EDIT: After working more on this, the user cannot be blocked and must be active / authenticated.
Using webforms, I have a form that has a field that a new user (blocked) needs to fill out to tell the ...
0
votes
1
answer
110
views
tempstore.private not working in openIDConnect client
I am getting some licence info via retrieveUserInfo in the openIDConnect custom client login process. Ideally i want to write it to the session but opted for the "tempstore.private" since it ...
0
votes
0
answers
34
views
Auto increment value less than max uid on users table
I'm seeing these errors flooding my log file.
They come from commerce order complete pages - and some registration pages too.
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity ...
0
votes
1
answer
41
views
With English, French and Spanish enabled. Recently our Comms folks can't add translations
We're using Drupal 9.4.10 - turned on content translation for the Comms role for all content types, URLs, etc. but that role cannot create translations for any content type. They can edit the ...
0
votes
0
answers
14
views
eCommerce Products Permissions per Node
Good day
We are building an eCommerce Platform where multiple users can be able to register, login, create, edit and delete their Profiles and Products.
The main feature is to have each user to only ...
0
votes
1
answer
91
views
Views Exposed filter can't input username to filter. Only works with User ID
I created a custom View, where it shows all of a specific content type. In this content type I have a field that is a user reference called "Assigned to". In this view, I want it exposed so ...
0
votes
1
answer
118
views
Logged in user data, after logout
I need the ID of the logged in user, after logging out. I tried to use a session variable, but all data is lost on exit.
Is there any method to use, other than the query parameter?
┌──────────────┐ ...
0
votes
1
answer
29
views
How to get "user pictures in posts" to not be greyed out/ disabled?
Setup:
Drupal 9 with Claro admin theme and Olivero default theme.
Scenario:
When I navigate to admin>appearance>settings>global settings, under the first section "page element display&...
2
votes
1
answer
241
views
checking route access for authenticated role
I'm outputting a link, made using Url::fromRoute(). If the current user is anonymous, and the route is not accessible to them, I'd like to show a 'Log in to use this link' text instead, simular to ...
1
vote
1
answer
359
views
Removing orphaned paragraph references from the user
Setup
Drupal 9 site has Users and each user has a Paragraph that contains "Phone" data.
User => Phone Paragraph connection is made via field $user->field_phone_para.
Issue
Somehow ...
0
votes
0
answers
161
views
Messenger doesn't display value after user logged out and redirect
After my user is submitting a form, I want to logged him out, then redirect to the front page. then, display a message.
public function submitForm(array &$form, FormStateInterface $form_state) {
...
1
vote
1
answer
111
views
How to display a user’s published content on their account?
Does anyone know how to display every article (or content type) a user has published on their "my account" view? To clarify, I only want it to display that specific user's published content ...
1
vote
1
answer
327
views
How to programmatically set a checkbox value of an user account which field is not in /people/accounts/fields
I need to set a checkbox which has an unknown field (machine) name in the user account. the checkboxes are in the user account /user/?/edit
but they doesn't appear as fields in people/accounts/fields ...
1
vote
1
answer
148
views
How to hide the tabs on the user account if it is not his account? [duplicate]
My users have permission to view other users' accounts. Only the "View" tab page. This is exactly what I want.
On the user account, by default, there are three tabs:
View
Shortcuts
Edit
...
0
votes
0
answers
384
views
I am logged in as admin user but I get a message saying I am not authorised to access the Update or Install pages
I am not able as user 1 to access the 'Extend -> Update' or 'Extend -> Install new module' pages (I can, however, access the 'Extend -> Uninstall' page). This has only started happening in ...
0
votes
0
answers
46
views
How can I update my staging with with the users from the live site?
I have a staging site I am about to push live, however I have a bunch of users on the live site that I need to pull over to the staging site before I push it up to the live site. I have google ...
0
votes
1
answer
15
views
Auto send userA's profile URL to userB
I thought this could be easy, but I don't know what's the best way to achieve this.
I have an acting "job" application site, userA need to finish his "profile2" first which ...
1
vote
1
answer
375
views
Replacement for hook_user_presave() for saving values captured in the user form to the user profile
I am porting a module from Drupal 7 to Drupal 9. The code uses hook_user_presave() to save two fields on the fly into the user profile data.
/**
* Implements hook_user_presave().
*/
function ...
0
votes
0
answers
58
views
Conditional filter for visitor role
I'm throwing a big number of views showing a list of 'events' (nodes) happening today, tomorrow and after tomorrow. I'd like registered users with role 'editor' could see all events from today (not ...
2
votes
2
answers
81
views
How do I display user signatures in comments?
Drupal 7 has a "personalization" section on ...admin/config/people/accounts
If this exists in Drupal 9, I'd love to know where it is.
The goal: enable signatures for user accounts.
If it's ...
1
vote
1
answer
20
views
Column of owner of webform submission in database
I need to find the column of the owner (user_id) of form submission in webforms. I need it in order to create some complex queries for the needs of the client. I looked in webform_submission_data and ...
0
votes
1
answer
20
views
How can I prevent Drupal from saving the user's initial email address? (init in the users_field_data table)?
I am trying to reduce the amount of PII (personally identifiable information) that my site collects.
When a user registers an account, by default, that email address is saved twice in the ...
0
votes
1
answer
36
views
How do I list all the roles to assign them in the registration form? [closed]
I'm trying to alter the user registration form by adding a custom field which lists all the available roles in the site.
How can I achieve this?
0
votes
1
answer
90
views
how can I add contextual links to each of the items in my view?
I am creating a view in drupal and I need that each of the items of this view (are publications) have a contextual link to access more easily to edit this publication. I have tried adding {{...
0
votes
1
answer
58
views
How to use the user profile photo as the default image in a content type image field?
I would like to pull the current user profile photo in a content type image field but the default image option only allows the admin to choose an image file. Is there a module that allows the admin to ...
1
vote
0
answers
42
views
Show user page only if displayed (and not current) user has a specific role
On my site, anonymous users can access user information with this type of url: /user/25
It works fine, I created a template for this branch: user–full-html-twig.
However, I would like this type of url ...
0
votes
2
answers
417
views
How to get newly created user id in user_presave hook?
Following is my .module file code
/**
* Implements hook_user_presave().
*/
function cost_sheet_user_presave($account) {
$source_userid = $account->id();
\Drupal::messenger()->...
0
votes
1
answer
29
views
How can I run a certain action when a taxonomy field value is removed or added? [closed]
I have a user_territories field which can have multiple values. I need to run a certain action when this field value is changed from the user entity, not when other fields are changed.
How can I write ...
0
votes
1
answer
224
views
"Unable to remove item at non-existing index"
I am currently working on Drupal 9 build of the Drupal 7 site along with just user migration.
The site had existing 20K users and we're migrating them with Drupal Migrate module with simple bring ...
1
vote
3
answers
113
views
Joomla user password to Drupal migration
I have a Joomla 3.10 and a Drupal 9 site.
I want to migrate user passwords from Joomla to Drupal. I have seen that Joomla uses bcrypt and Drupal uses sha512 as the password encryption.
Is it possible ...
1
vote
1
answer
41
views
Anonymous User name is changed to a strange name in watchdog logs [closed]
Our D9 site's dblog is showing the anonymous user name as a very stange name instead of anonymous. All anonymous users are shown as "closhewupheheh…" even though the anonymous user name is ...
1
vote
1
answer
389
views
Send "admin (user awaiting approval)" email programmatically to admin
I want to send the "admin (user awaiting approval)" email after creating an account in the user_insert hook
I don't know what function is used. I did find _user_mail_notify which works well ...
0
votes
1
answer
247
views
Comparing 'old' values in hook_user_update
I've got a function which is running on hook_ENTITY_TYPE_update for the user account, but I want to be able to compare against previous values that may have been on the user account, eg see if the ...
1
vote
0
answers
25
views
Why am I getting different results for entity::save() between REST and web?
I'm refactoring my user entities to use entity bundle classes.
Before, I saved the value of a time offset in a field using hook_user_presave():
// Initialize in user timezone.
$user_timezone = ...
0
votes
0
answers
76
views
Login fails: returns to anonymous user home page with no message
I am testing upgrade to Drupal 9. I upgraded core and logged in and fixed a few issues with module deprecated code and then was presented with a Twig issue where replace syntax had changed. I changed ...
1
vote
0
answers
65
views
Unable to have user role permissions correctly applied
I have a multi-language site managed by different admins. We want to create a news editor role and apply it so that a) the person can only modify content applicable to their language and b) can only ...