Questions tagged [users]

Use it for question about the user entity, once the most important Drupal entities. Don't use it for a generic question about, for example, what users can do on a site.

Filter by
Sorted by
Tagged with
1
vote
0answers
36 views
+50

Referencing disabled users during migration

I have migration that creates files. For file owners I'm trying to find existing user by email and if don't find I create one on fly. Problem is that those users I'm creating must be disabled (I don't ...
0
votes
1answer
41 views

How do you remove a user role via a hook update?

I would like to remove a user role via a hook update in Drupal 9. I believe I would need to do something like the below but unclear what other code might be needed. $user->removeRole('administrator'...
1
vote
2answers
208 views

How can I force user logout from a JavaScript library in a custom module?

I've written a custom module for Drupal 8 to monitor user device location frequently. If a user goes out of an allowed zone boundary, I need to force logging the user out of the website. I created ...
2
votes
2answers
88 views

add field to user in hook_update_n

The latest release of our existing module needs to define MANY new fields that are attached to the drupal user. For each field, in {module}/config/optional there is a field config and a field storage ...
0
votes
0answers
17 views

How to distinguish new users who haven't validated their email?

How can a site manager filter the list of users so they only see new users who have validated their email addresses? Registration to the site requires approval, and the site manager does not want to ...
0
votes
1answer
22 views

Can users with a custom role approve the user registration?

I have created a site that requires approval of new user registrations. I added the Manager role for the site owner. I'd like users with that role to approve the account registrations. Is there any ...
0
votes
0answers
32 views

How can I get specific fields from user object in the REST API?

I have a question about retrieving fields from the user object using REST in Drupal 8. When i am logged in into Drupal i can use the following GET call too retrieve the user object: http://localhost:...
1
vote
0answers
31 views

Restrict users from creating administrators?

I want to give some users the ability to add and edit other users, but I don't want them to be able to add administrators (or for them to be able to give themselves or other users the "...
1
vote
1answer
193 views

How can I programmatically delete a user without deleting their content?

I want to delete a user with this code: $account = User::load(19920); $account->delete(); How can I do that without also deleting the user's content? I've been reviewing _user_cancel() hooks, but ...
1
vote
1answer
66 views

How can I bulk delete users? [duplicate]

My site got hacked and I had an online service clean it out. However, it now has over 150,000 user accounts, the bulk of which have no role assignment. How do I delete these accounts and their content?...
0
votes
2answers
75 views

Map profile_id based on previously mapped uid when migrating user profiles from CSV file

I'm trying to migrate users and user profiles to site, where both entities might be already present. In this case I would like to overwrite specified fields and leave others in the original state. I'm ...
1
vote
1answer
90 views

How to determine which password hash is used?

We have migrated website from a vanilla coded PHP to Drupal, and I have also migrated all the users. The old website has been using the password_hash() function to encrypt the password. The website ...
-1
votes
1answer
67 views

How do I get the (integer) uid from the User entity?

On the odd chance there was a "getUid()" method for the user entity, I tried it, but got: Call to undefined method Drupal\user\Entity\User::getUid() Is there a way to get the uid from the ...
0
votes
0answers
35 views

Cannot add user picture for administrator

I installed 2 servers with Drupal 9.1 and I updated to Drupal 9.2 I just noticed that there are problems with the modification of the administrator account "user 1". In the list of users, ...
0
votes
1answer
439 views

How to get current user jwt token?

In a custom module, I need to get the jwt token (access_token) related to the current user. Following this issue I've tried to get it, but without success, because get_jwt_key() and jwt_token_params() ...
1
vote
1answer
31 views

How to display 'Welcome [first_name] [last_name]' in a custom views block? D8

I would like to create a custom block / view to display a welcome message to the currently logged in user in Drupal 8. I followed this answer but it isn't working for me. Maybe things changed in D8. ...
1
vote
0answers
17 views

What is the specific security implication with the permission "Select method for cancelling account"

Below the permission "Select method for cancelling account" there is the following hint: Warning: Give to trusted roles only; this permission has security implications. I understand that ...
0
votes
1answer
29 views

How do I let users cancel their account with JWT / JSON:API?

I am making an Ionic app with Drupal as the backend. Users log in via JWT. I'm using JSON:API to send data to Ionic. Now I want to allow users to cancel their accounts in the app (by JSON:API) ...
0
votes
0answers
19 views

Account Settings: "Access Denied" on emails translation

I'm having issues for accessing the "Email Notifications" from user configuration in Brazilian Portuguese. All Developer Portal "User Email Notifications" are being sended in this ...
0
votes
0answers
48 views

How can I sync just roles/permission config across multi-site instances?

On a Drupal 8 multi site, we need to have unified ROLES/permission config in all sites. Then we'll assign these roles to users via interface or Drush. How could I export / import? Or even better sync ...
0
votes
1answer
70 views

Does the login-link users receive upon registration actually expire?

I'm trying to expand the duration for the expiration of the one-time-login for the initial registration process: the user clicks on "create new account" after filling name and email and ...
1
vote
1answer
54 views

how to set a node to anonymous author?

Change node author works : $node = \Drupal\node\Entity\Node::load($nid); $node->set('uid','45'); $node->save(); But i don't know how to set it to anonymous user ? or unset it ? $node = \Drupal\...
0
votes
1answer
40 views

How to get the contents created by a User?

How to get all contents from which the current user is author? $currentUser = \Drupal::currentUser(); $user = User::load($currentUser->id()); //get the contents from which $user is author?
0
votes
0answers
377 views

How can I programmatically create an user account and trigger an activation email?

I developed custom module to create users. And I setup config account setting "Require email verification" to "Require a verification email, but let users set their password directly on ...
1
vote
0answers
91 views

Can I cast a generic type reference (EntityInterface) of an object, to a more specific, AccountInterface, if I know the object is a user?

Here is my code // implements hook_node_presave function mymodule_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { if ( $entity->getEntityTypeId() === 'user' ) { so now I know the $...
0
votes
0answers
82 views

Error message for duplicate email for user registration

On my site, users sign up by submitting their email and name to a user registration form. They will get an email with a link that will allow them to complete the rest of the sign up process, like ...
0
votes
0answers
15 views

How do I automatically add a user to a group when a user role is added to the account?

What I would like is that when a Drupal user has a User Role added to their user, then this also adds them to a specific Drupal Group. When I talk about User Role, I mean the standard User Roles ...
0
votes
1answer
37 views

Headers already sent

I found this error repeated several times for two of the pages on my website. Warning: Cannot modify header information - headers already sent by (output started at /home/customer/www/mydomain....
1
vote
2answers
269 views

How do I get group to which the node belongs and redirect anonymous users to the login page if they land on it?

I'm using the Drupal Group module and I've added content to a Drupal group I've created. I've also added users to this Group. Works well: Drupal users have to login to see this content in that group. ...
2
votes
2answers
227 views

PostCreate/Hook on User Registration

I want to hook into user registration but there doesn't seem to be any hook for it anymore. This is what I see from Drupal 8.8: hook_user_cancel hook_user_cancel_methods_alter ...
1
vote
1answer
104 views

Migrating user accounts to Okta

I'm trying to migrate users exported from Drupal into Okta using the /api/v1/users API (specifically [creating users with import hash][1]), and am stuck, and desperate for help as I'm late on a ...
0
votes
0answers
35 views

How to redirect logged in user to different page rather than what is configured in basic site setting? [duplicate]

I have the following requirement: When an anonymous user visits the site, they will get /login page which is configured in Configuration -> Basic site setting -> Front page. After logging in ...
0
votes
1answer
27 views

How can I conditionally create a user account based on field in registration?

Here is the scenario: Prospective employees (PE) who need to access this Drupal site for onboarding resources will be sent an access code from someone in HR (to prevent random people from creating ...
4
votes
3answers
655 views

How to implement decoupled user registration with React / jsonapi?

I have built a React app that uses JSON:API to pull in data, but now I want to implement user registration. JSON:API doesn't do user registration because it isn't a CRUD operation. However, the links ...
0
votes
0answers
40 views

How can I migrate users?

I need to rebuild my website, actually built with Drupal 7, and install Drupal 8. I have some modules that don't exist in Drupal 8. So, I decided to install Drupal 8 and rebuild the website from ...
0
votes
0answers
22 views

Is there a way to ouput variables in a custom module?

I'm updating a custom module and I would like to output the $node and $user variable to see what is in it for a specific key. The value of this key can be one or multiple strings and I'd like to know ...
-1
votes
2answers
83 views

Updating user leads to sql integrity issue

Please help me find what I am doing wrong to update a user field. I am trying to update all existing users in my Drupal 8 instance. I could do the same thing easily in D7, but can't get it working ...
0
votes
0answers
32 views

I've placed blocks in hidden region, now no login to admin possible

I made a site in Drupal 9. I played a bit with blocks and I think I placed an important block in the hidden region. Now the login page doesn't show the login form anymore. The header, footer and some ...
0
votes
1answer
117 views

How to create Media entity and attach to user field

I'm trying to import user profile pictures from Drupal 7 to Drupal 8. So far I've managed to upload the picture from the url and save it to the file system, create Media entity and use the user id as ...
0
votes
0answers
27 views

Can't upload anonymously using webform

I am using varbase 9.0.0-rc1 distribution I have successfully uploaded files using the forms while I am logged in. But anonymously I get the following error: An error occurred while attempting to ...
5
votes
1answer
397 views

Locked myself out after enabling misconfigured Google Authenticator

I somehow managed to lock myself out of a Drupal 9 installation after setting up TFA with Google Authenticator login. So, i know my user1 name, my user 1 password, but TFA doesn't allow me backend ...
0
votes
0answers
41 views

User's Name, Roles and Mail not accessible throughout the CMS

I'm trying to access different properties of a Drupal user, such as name or mail, but they are not accessible, either from Drupal Rules module or from the emails sent when a new user has been created ...
3
votes
0answers
107 views

How can you require users to change their passwords on first login after migration?

We are planning to migrate users from another CMS to Drupal. We can migrate usernames, but not passwords as the encryption is different. So we shall have to assign passwords to them. Earlier versions ...
0
votes
1answer
198 views

How to migrate password with hash

I'm doing a user migration from Drupal 7 to Drupal 8 (the data is in json format) Most of the fields have been imported to the new website. Now, I'm in the process to migrate the password; this field ...
0
votes
1answer
192 views

How do I log in a user?

I want to log in Drupal 8 users from an external PHP file. I am trying the following code. use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; use Drupal\user\UserInterface; //$...
1
vote
2answers
80 views

Batch delete users and the content they created

When I received this Drupal 7 site to manage, it has had years of being open for people to make accounts and now I have ~ 300 PAGES of users with names like ismehacker1234568 and such, with under a ...
1
vote
0answers
48 views

How can I reliably login by username in hook_form_user_login_form_alter for SSO?

I'm integrating SSO for one of my Drupal 8 websites. We have on-premise SSO and getting user details and respective user roles from SSO response. When I try below code, sometimes it works. Sometimes ...
1
vote
1answer
53 views

Inconsistent behavior with user_logout function

For a drupal 8 site, I have a custom function that does the following: It logs out the user and sends them to an external url Inside the controller CustomController, I have: function custom_logout(){ ...
0
votes
1answer
89 views

SMS password recovery

I'm currently using D7. When my users attempt to request a password reset, 95% of the time, these reset emails land in their spam, or are blocked by whomever their email provider is. That being said, ...
0
votes
1answer
23 views

How to set role on the registration form programmatically

I'm trying to create multiple registration forms with a role assigned to each. It seems that my default value for the role is not keeped, but it works with other fields Here is my code $form = $this-&...

1
2 3 4 5
131