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,524
questions
1
vote
1
answer
60
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
36
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
28
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
26
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
66
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
14
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
0
answers
15
views
How to prevent certain users or user roles from being able to send private messages to another user or user role?
With the Private Message module (https://www.drupal.org/project/private_message), I have pretty much found what I have been looking for. With this module, users are able to write private messages to ...
0
votes
1
answer
35
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
10
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
39
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
71
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
23
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
93
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
158
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
91
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
71
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
185
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
109
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
90
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
40
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
159
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
55
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
66
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
15
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
14
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
31
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
43
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
0
answers
58
views
View displaying content revision with a relation to a user field
I have a following use case for building a view in D9 that is causing me problems.
Each user has a custom field that refers a taxonomy. Let's say it's a list of departments users belong to. Each user ...
0
votes
1
answer
50
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
27
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
204
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
26
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
164
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
97
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
32
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
250
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
0
answers
175
views
Redirect after using the one time login after password reset
How can i programmatically change the button link destination after clicking the one time login button in drupal 9:
I've tried this solution but got stuck because i didn't know how to compare a link ...
0
votes
1
answer
125
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
65
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
42
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 ...
1
vote
1
answer
316
views
Wrong user with currentUser() on prod
I'm getting the name of my user that I load from the profile. It's works fine on my local, but on my prod, the firstname displayed is showing the name from the previous user. How do I prevent that ? ...
1
vote
2
answers
160
views
How can I encrypt user-submitted content per user for a content type?
Let's say I have a website where people keep a personal diary (diary content type). I have configured permissions so that each user can only read, write, and view his/her own diary.
Users can create ...
1
vote
1
answer
75
views
Permission granted to a programatically created role is not working!
In a custom module form, I am using this code for the submission handler.
$role = Role::create(['id' => 'member', 'label' => t('Member')]);
$role->grantPermission('Renew membership');
$role-&...
2
votes
1
answer
254
views
How to remove user role temporarily?
I need to disable the "administrator" role from user accounts who log into my website from outside my network. For security, I only want users who have this role to be able to use it when ...
3
votes
1
answer
476
views
Cannot add new user due to "Integrity constraint violation: Duplicate entry" error
Starting December 14, 2021, my site began creating users with low user IDs, even though the highest-used user ID was 9317. I thought something had been changed in a core update to reuse IDs that had ...
2
votes
1
answer
446
views
How would I disallow special characters in usernames?
By default, Drupal 9 allows usernames to have spaces, periods(.), hyphens(-), apostrophes('), underscores(_) and @ symbols.
How would I disallow spaces, periods, apostrophes and @ symbols?
0
votes
1
answer
325
views
"Access denied" Error on clicking user/reset link [closed]
I am a Drupal newbie, so pardon any errors in my question. In my D9 site I am using password policy module to set password policy rules. When I hit "Reset password" I get a one-time link to ...
0
votes
1
answer
65
views
store user entered mail id to separate table
Have a requirement to develop drupal 9 custom module to get the mail id from the user registration form and store it separate table. I tried the hook_user_presave function to get the mail id but was ...