Questions tagged [users]

One of the most important entities Drupal uses is the user entity.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Custom User Field Hook_query_view_alter()

I want to dynamically filter a view using the hook_view_query_alter. My goal is to be able to display all the users for the sub-admin in a view that has the same custom field as it. But I don't ...
0
votes
1answer
20 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
14 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. ...
-2
votes
0answers
53 views

Custom folder access per role [closed]

I need to restrict access of custom folder for some user role. I have flip-page book in one folder with index.html file and other files in subfolders. So I need to restrict access of that folder to ...
1
vote
0answers
16 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 ...
1
vote
1answer
17 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
13 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
33 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
0answers
9 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: user clicks on "create new account" after filling name and email and sending ...
1
vote
1answer
42 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
35 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
47 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 ...
0
votes
1answer
28 views

user deletion : user_cancel_reassign not working when user has more than 10 associated contents

I am attempting to suppress Users with no permissions/roles from our sites. The user associated contents should be kept on user deletion. This code below works when the user has a few associated ...
0
votes
0answers
39 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
51 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
13 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
27 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....
0
votes
2answers
50 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. ...
0
votes
1answer
17 views

Users chosen from a field in a content type see only their result

I have a list of students who are users in my Drupal 8 site. I want to publish their result but I want each student to see only his/her result. I have a content type where I can get marks and an ...
2
votes
2answers
36 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
64 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
23 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 ...
3
votes
3answers
266 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
31 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
19 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
46 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
65 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
24 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
390 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
39 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
74 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
56 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
76 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
40 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 ...
0
votes
0answers
11 views

How to add a password reset link in the “Administration Views”

The administration views on drupal 7 https://www.drupal.org/project/admin_views replaces user page with a new views. I would like add a password reset link which would send a password reset email to ...
0
votes
0answers
77 views

Multi-site user share with different databases

I am trying to setup multi-site on Drupal 9.1 using a shared codebase with separate databases. Working within each site separately has been fine, and I'm ready to start working on sharing users and ...
1
vote
0answers
36 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
43 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
46 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
0answers
7 views

How do i hide a views field(button) based on rolde?

I have a question, I have created one custom button by altering the view and now i want to restrict that button for few roles like for role 1 & role 3 it should visible but for role 2 & role 4 ...
0
votes
1answer
21 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-&...
0
votes
1answer
33 views

Which hook to use to detect new members added to group?

What is the best way to make a hook that only fires when new members are added to a group? I have a function that exports group memberships to moodle course enrolments. Right now I have it bound to ...
0
votes
1answer
76 views

How to display the user's preferred language in a User profile page

In a Drupal 8/9 site, I can select the User's preferred language. In the "Manage form display" page (for user's fields), there are two rows which are about language: Language settings (...
0
votes
1answer
57 views

How do I access profile fields? [duplicate]

I have installed the Profile module. I am trying to programmatically load profiles. The code works, but I am not able to access any field value. class IdCardController extends ControllerBase { /** ...
1
vote
2answers
59 views

Programmatically uploading and validating a user_picture

I use the following code to modify the image in the user_picture field of user with uid 42: // Get user. $user = \Drupal\user\Entity\User::load(42); // Create file. $file = file_save_data( ...
-1
votes
1answer
50 views

How to update the TWIG flag conditions?

I have this code in my sub theme : bootstrap_subtheme_front_office_old.theme <?php /** * Implements hook_preprocess_HOOK() for user.html.twig. */ function ...
-3
votes
1answer
46 views

Unable to display message when account is flagged

I have this code in my sub theme : bootstrap_subtheme_front_office_old.theme <?php /** * Implements hook_preprocess_HOOK() for user.html.twig. */ function ...
-1
votes
2answers
47 views

how a user can add another user but this is not an admin [closed]

I have 5 roles (Admin, HRM, Registrar, Staff, and HOD). Admin users will give special access to HRM users to add new users whose role is Staff. Registrar and HOD roles shouldn't be shown in the Add ...

1
2 3 4 5
132