Questions tagged [users]

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

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

Programmatically validate a user [closed]

I have created a webform which when submitted will create a new user for my Drupal 8 site. The user must enter his username, email, and some additional data. I am using below code to create & ...
0
votes
1answer
44 views

How can I create an entity reference field to list a subset of roles?

I want to provide a field in a node to lists a subset of available roles. These roles could be used to decide how the node would be displayed to users with the roles selected here. Is there a way to ...
1
vote
2answers
47 views

How do I add CSS body classes for logged-in and logged-out users?

In Drupal 7 I would add a theme process function to add the body classes needed. function template_preprocess_html(&$variables) { $variables['classes_array'][] = $variables['is_front'] ? 'front'...
0
votes
2answers
52 views

How can I retrieve a user name and password?

Someone installed the drupal 8 site and did not share the password. I do not know what email he has used to install the site either. I do not have the password. In phpmyadmin, I clicked the database ...
1
vote
1answer
37 views

hook_user_insert not being called

I've got a custom module weekly_digest and I want to make it so each new user is added to a table with info on their subscription preferences. I've been using the admin UI to add the users to test, ...
0
votes
2answers
22 views

How do I fetch the user ID from the shipping profile?

I'm trying to get the User ID from Shipping Profile in Drupal Commerce using the following code, but eventually, $entity->getOwnerId() is returning me NULL in any case, if it's an authenticated user ...
0
votes
0answers
30 views

How to get user password before it is hashed?

In Drupal 8 - how can I get the user password BEFORE it is hashed? I need to create the user at two other services through API's, so the user can use the same credentials to login to all platoforms. ...
1
vote
1answer
49 views

Compare a single value entity reference field to a multi-value entity reference field

The article entity has an unlimited multi-value Taxonomy reference field field_article_countries referencing the Taxonomy vocabulary Countriesand the User entity has a single value Taxonomy reference ...
1
vote
1answer
58 views

How can I prevent user data being cached and showing the wrong username?

I have built a Drupal 8 site, we are showing the user name and last name on a block, this is my code on preprocess from .theme file: $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->...
1
vote
1answer
29 views

How do I implement access checks based on referring nodes in the grants system?

Following a suggestion in another thread here I'm trying to rewrite the access restrictions that I developed using hook_node_access (and that are working well, so far) in Drupal's grant system (i.e. ...
3
votes
1answer
134 views

How can I share cache with multiple users and roles?

In my custom module, I define a custom block that performs an expensive operation: /** * {@inheritdoc} */ public function build() { $data = get_expensive_data(); $agent_number = ...
0
votes
1answer
23 views

Override user register default URL to set up password

in order to create a sign in/sign up workflow on a decoupled Drupal(React on front). I've used the core provided rest resource /user/register with Rest ui, and after giving the permission Access POST ...
0
votes
0answers
20 views

Include multiple profiles per user in webform data

I have a profile type that allows multiple profiles per user. Users have different numbers of profiles. I'm trying to include this variable profile data in webform submissions tied to the profile(s)-...
0
votes
1answer
14 views

Why are new users having their role deleted on signup?

Today my client added some new users & gave them a role, and checked 'Notify user of new account'. The users clicked the email link, entered their password and all was well - except that the role ...
0
votes
1answer
28 views

Compute values to display on the user profile page based on other user profile field values

I've added fields to user profiles: subscriber (yes/no) guest subscriber (yes/no) print subscription expiration date online subscription expiration date On the user profile page, I want to display ...
0
votes
1answer
18 views

How to insert value to user entity custom field while creating new account?

I am trying to insert a value into a custom field(field_custom_referral) which is created in the backend.When a user creating a account in our application, this particular custom field should be ...
0
votes
0answers
15 views

Hide Publish State Option on Node for specific role of user

For example I have allowed visitors to register/login for writing a blog post, so I just want to remove/hide publish option in specific Node (blog) for writers, they can set state of node as draft/in ...
2
votes
2answers
43 views

Which event should we subscribe to if we want code to be triggered when a new user registers?

I noticed that the following event is defined for when a user account is 'set const SET_USER = 'account.set'; I want to execute code by creating an event subscriber when a new user registers on the ...
0
votes
1answer
37 views

How to restrict access to view a block for a certain role? [duplicate]

I have some custom roles such as Premium Membership and I don't want to allow access to this category. The authenticated role is included to Premium Membership or Moderator users because every ...
0
votes
1answer
29 views

How to add password reset link to user page?

Is there an easy way to add a password reset button to the user page in drupal 8? For user management I need the admin to be able to send password recovery link to users AFTER the user account is ...
1
vote
0answers
31 views

How to trigger a rule whenever users update their picture

Using Drupal 7 and the Rules module I need to trigger a rule whenever users update their user-picture. I tried using the event "After updating an existing user account" which does trigger the rule, ...
0
votes
0answers
12 views

Multistep sign up, force user to create node before they can access site?

Im using Drupal 7. I want my users to either create a node or flag a node before that can access the rest of the site. I have created a view of content, and added filter either current user is node ...
0
votes
0answers
21 views

Is it possible to add “Options” to an User Reference

I have an Content Type called Account. My website Users are then linked to the Account entity using an Entity Reference field on the Account content type. I want to be able to assign different ...
0
votes
0answers
27 views

Disable error on user login / register form

I've been trying to disable the error on top here : I have not been able to find the source of it. Doing messagesByType(TYPE_ERROR) does not return this error. I can see it within $_SESSION['...
0
votes
1answer
31 views

Is there any way to get only the custom roles?

I would like a list of all custom roles. Currently I am loading all of them using $roles = $this->entityManager->getStorage('user_role')->loadMultiple(); but am wondering if there is any ...
0
votes
0answers
38 views

How do I control which tabs a block is displayed in?

Drupal 8.8.1 with commerce 2 installed. Goal is to make better use of the ‘logged-in user’ landing page(My Account) by adding blocks of useful content. Blocks created using the UI as well as coded ...
0
votes
0answers
29 views

Disable/Hide buttons in view table based on role

Is there any way to disable/hide certains buttons/links in a view table based on role? I want to display admin buttons/links in drupal commerce for all the orders if the user/role is admin, customer ...
0
votes
1answer
41 views

How do I display a username on their profile pages?

Using Drupal 8, I simply want a user's profile (or account) page to show its username, like so: For username "bob": Username: bob Do I add a computed field? What's a line of code would I use?
0
votes
0answers
40 views

How to render a webform inside Entity form

My drupal system has the user entity with a field webform submission. The system has more than one webform also. What I need is, Whenever a new user came to register, the registration form needs to be ...
1
vote
1answer
37 views

How do I programmatically create a node with an entity reference (to an user)?

It is kind of strange because my code creates the node with the referenced user uid in node_field_data, but when I open this node the user reference isn't working. Then I navigated the database and ...
1
vote
1answer
103 views

How can I print user field values in page.html.twig?

I've created a couple of fields for the user in Drupal 8, example: first name. And i'm trying to print it in the home page (page.html.twig) but to no avail. I tried the following: {{ user....
1
vote
1answer
40 views

How do I change the salt used for the user password when creating an account?

I am working on Drupal 8 site where the client has asked us to use their own custom salt when storing the user password in the database. Is it possible to set a custom salt for a Drupal site? The ...
0
votes
0answers
9 views

Entity reference add users autocomplete, autofill email in multiple fields

I have a D7 content node content type which has an entity reference users field with an autocomplete widget, addressfield. When I select an user the user entity and addressfield is automatically is ...
1
vote
1answer
18 views

How to get one time URL when we are writing hook_mail_alter?

My Question is already present here but the previously given answer for my question can applied to Drupal 7 and I can not use the same solution in Drupal 8. I hope it is okay not put the same ...
0
votes
0answers
11 views

How to make global permissions available in OG Role permissions?

In OG Role permissions only some are listed, not all that are available under drupal site wide roles. I want to make a global permission available under OG Role permissions, as I need to make the "...
-1
votes
1answer
62 views

Redirecting Anonymous Users to external URL on Drupal 8 site

Still pretty new to Drupal, but I am attempting to create a custom module that redirects anonymous/unauthenticated users away from the site. This site is only supposed to be used by admin's so in ...
0
votes
0answers
20 views

Track/Log changes to permissions

I was trying to find contributed module for Drupal 8 to track practically everything users do on site. I was able to find some good modules like Events Log Track but it only works for entities (...
2
votes
2answers
244 views

Write complex access control in a reusable way

We deal with nodes representing humans with two important properties: mother and father. Your parents as well as your aunts and uncles should get extra permissions, like to see you in a certain view ...
-1
votes
1answer
29 views

How does drupal 8 handles redirect respose? [duplicate]

Iam using a RedirectResponse in drupal 8 in my custom module when a user is logging in, $user = User::load(\Drupal::currentUser()->id()); $userRoles = $user->getRoles(); if(in_array('admin',$...
1
vote
1answer
54 views

How do I re-save all users?

I need to re-save about 300 user to initialize geo-coding on their address fields. On /admin/people, I don't see any bulk action that would fit my needs. I have tested the update path-alias but with ...
0
votes
0answers
48 views

Hook into password change on user update

Question in short: How do I hook into password change in order to get plaintext old and plaintext new password when password change is accepted? What I have tried so far: I tried hook_form_alter with ...
0
votes
0answers
51 views

Show admin field based on field value

In the admin of a certain Content type (node/31/edit), I Added a select list field field_hero with two key|value's: carousel|Carousel video|Video when the site editor select carousel, I want to ...
0
votes
1answer
13 views

Changing field instance display settings for view_mode

Background In the user.module file in user_build_content(), there is a line that adds fields for a given view_mode: $account->content += field_attach_view('user', $account, $view_mode, $langcode);...
0
votes
1answer
60 views

Change default format for date field on user register form

I'm new to Drupal 8. In the user registration form, i've added a Date field via manage fields in user account settings. However, I need to customize this field and change its format. I tried 'manage ...
-1
votes
1answer
36 views

Accessing user email from object of type \Drupal\user\UserInterface

If a method of a class is returning an object of the interface \Drupal\user\UserInterface How do we access the user email of that user?
1
vote
1answer
47 views

How Do I Change My Drupal Admin Password From a Drupal Test Install on My Local Machine [closed]

I am a complete Drupal beginner. My Drupal site is hosted with a provider. I have these questions and would really appreciate your insight. 1) I want to be able to change the front end log in pass ...
0
votes
1answer
25 views

Print module theming address for user page

I am using the print module to have print-friendly pages. I followed theme suggestions, I could not make the theming work for user pages. So far, I tried the following I would like to theme user pages ...
1
vote
1answer
70 views

How to run alterRoutes on particular condition ? Does it run on cache clear and not on normal Request?

I am trying to implement a feature where I need to run different flow than default flow while the registering user on the site. I am trying to alter the route of "user password reset" for the for the ...
0
votes
1answer
37 views

How to add/remove a permission from a user role to a particular user without modifiying the user role?

Let's say that I have a user role called ARTICLE_VIEW_EDIT which has permissions to view and edit own articles nodes. I have the following 2 cases. I want to give extra permission, delete own ...
2
votes
1answer
46 views

How to manually check if a username and password is correct? [duplicate]

There are a lot of answers on how to log in as a specific user. But I can't find any answer on how to check if the username and password is valid without logging in. I want to be able to do something ...

1
2 3 4 5
131