Questions tagged [users]

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

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

Deny access for Authenticated Users

I'm using the moduke Permissions by Term and I love it. It works great and my complete system is now build around it. But I ran into a certain case and I am wondering if this is even possible. I ...
1
vote
1answer
16 views

Drupal 8 correspondence to node_access function on Drupal 7

I feel like asking a silly question, but here it is anyway: I need to test if a given user (in my case, the logged in, current user) has access to a given node for one of the existing operations (view,...
0
votes
0answers
10 views

Add property labels from address field properties in the view display

I use address field module and added this field to my customer profile (for Drupal Commerce integration). In the form you see decently the labels above the input fields (frontend). After filling in ...
0
votes
0answers
17 views

user_login_submit doesn't work when called in an inner function

We have a shared register function that multiple pieces of our app use. When registration is successful, we log the user in. But for some reason, when a user completes this project via browser in the ...
-1
votes
1answer
14 views

Remove Passwords match: text from Registration form

How do I remove/disable "Passwords match:" text in Drupal 8.
0
votes
3answers
56 views

How to redirect a user on login?

I have a registration form, when submitted, the user gets logged in automatically. I want to redirect the users to a specific page on login. Whether they are logged in using the login form or through ...
0
votes
1answer
21 views

How can I programmatically deactivate multiple user accounts?

I have tried the following code, but something doesn't work, could you please help. I need to deactivate several accounts at once, if they satisfy the conditions: $ids = \Drupal::entityQuery('user') ...
0
votes
0answers
21 views

What is the appropriate hook for hiding/editing user data?

We have a field on the user that I just need to hide one field from. This user object may be loaded from an API service endpoint or just in a regular login. Is there a hook I can use to obfuscate the ...
1
vote
1answer
41 views

How to create a user with custom fields?

On my drupal site, using the User module, I have added extra fields to the user registration form such as 'Organization'. I notice that this has created a mysql database called '...
0
votes
0answers
34 views

There was a problem creating field: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

I've recently downloaded a Drupal website to work on a local host (xampp). After importing the database, changing the base_url and running the update.php script, I managed to make it work. However, ...
0
votes
0answers
51 views

Form errors cannot be set after form validation has finished. When trying to edit user password in webform presave hook

I'am trying to edit a user account based on the values submitted through webform, the webform is Ajax enabled and I'am using the following code to achieve this. function ...
2
votes
1answer
67 views

How can I redirect a user after login to the current page? [duplicate]

I have a Drupal 8 site. And I have approximately 5 pages in a site. For example if a user hits login from the contact-us page the user should not redirect anywhere, they should stay on same page. How ...
0
votes
2answers
25 views

How can I have a employee ID read-only in Drupal Profile, set by Admin?

I need to have a field in user profile named Employee ID, this field should only be set by admin (Read and write), read-only to user, and hidden from all other users. Thank you.
-1
votes
1answer
19 views

How can I programmatically create a Profile 2 profile?

I am taking a look in the Profile 2 API documentation: http://api.drupalhelp.net/api/profile2/function I guess profile_create() or profile2_save() are what I need. But I have read somewhere ...
0
votes
1answer
31 views

Querying the user list from the database

There is a need from a different team in our organization to provide a periodic export of users, roles, and users-roles relationship data in a certain Aveksa-specific format. Where (which table(s)) ...
0
votes
2answers
22 views

Rules Redirect User at Login by Role to URL not working

I am trying to redirect any user with a particular Role at login to a URL. I am using Backdrop (Drupal 7). I have looked at most of the posts relating to this problem, and tried many of the examples ...
2
votes
1answer
48 views

notify user account creation?

I can't seem to find documentation for notifying a user via email after their account has been created by a script. $user = \Drupal\user\Entity\User::create(); $user->setPassword('xxx'); $user-&...
0
votes
1answer
36 views

“Username unknown” when programmatically creating user in hook_ node_presave

I have created content-type BookNow. In this I added field like Address, username, email, fullname.. I want to when submit booknow form than it can automatic creating new user which have own ...
0
votes
0answers
14 views

Is there a way to create a view filter to show users whose names are nonsense / random characters? [duplicate]

I am trying to purge my Drupal site of spam users. I have set up a page where I can filter users by email address, name, created date, etc. I would like to have a filter that checks the name field to ...
0
votes
0answers
38 views

Get user field value in Twig

I have a node--contentype.html.tiwg as well as a node--contentype--full.html.twig file in my template. In this files, I can get the nodes fields without any problem via {{ field.content.field_name.0 }}...
1
vote
1answer
26 views

How to modify the D7 user login page html to remove the register and new password options for non-admins?

So, I'm maintaining a Drupal 7 site for which we recently switched the users over to SSO through a third-party OAuth provider. The implementation isn't fancy, but added a login link to what I assume ...
0
votes
1answer
23 views

Forward authenticated user to user.page on /login uri

If an authenticated user navigates to /login on a Drupal 8 site, she gets the "access denied" error. I want the site to redirect that user to /user (route user.page) instead. Unfortunately my ...
1
vote
0answers
28 views

Respecting permissions in getStorage('taxonomy_term')?

Edit: I just realized that Taxonomy permissions are not native to Drupal core, they are the result of a module we activated: Permissions by Term. (This will explain why they are not being respected by ...
1
vote
0answers
75 views

How do I migrate accounts?

I am trying to migrate user accounts from a Drupal 7 site to a Drupal 8 site. On the Drupal 8 site, I have a module that programmatically adds users using the following code. $user = User::create(); ...
0
votes
1answer
40 views

Recover a deleted user's content

A few weeks ago a site admin canceled a user account on one of my Drupal 7 sites and clicked on "Delete the account and its content." That user had created about half the content on the site in ...
1
vote
0answers
25 views

Is it possible to provide a temporary role to an anonymous session?

Use-case is to provide a set of permissions to an "anonymous" user i.e. we don't know who they are and they haven't logged in, we just have their IP range to confirm where they're coming from (yes I ...
1
vote
1answer
38 views

How to update custom paragaph which is added to User Profile?

I have a requirement to create/update a paragraph which is added as a custom field in USER profile. After surfing here, i got how to update a paragraph which is connected to node. But I am not able ...
0
votes
0answers
31 views

Getting white screen in Login /user and the page content

I was recently editing a website with Drupal 7 installed, and was integrating twitter feed. I created a block twitter_feed_block and assigned the block to the content section of the front page. It ...
0
votes
1answer
11 views

Anonymous permissions with Nodeaccess

Content type: Webform Allowed grants: View, Edit Allowed roles: Anon, authorized, admin Go to the webform node eg. node/20 Click Grants tab Tick authenticated and admin users can View, anonymous is ...
-1
votes
2answers
52 views

How to detect the ip address of the device itself?

Using PHP and Drupal 8, I am trying to detect the ip address of the device itself and not the ip address of the router where the device is connected through the internet. $DeviceIP = \Drupal::request(...
0
votes
0answers
35 views

How can I update an user field via JSON:API?

How do I update user field via JSON API with D8? EndPoint:https://domainname.com/jsonapi/user/user/ Method:PATCH Request Header; Accept:application/vnd.api+json Content-Type:application/vnd.api+...
0
votes
0answers
20 views

How can I login via REST?

I am trying to login via REST API in Drupal8. Many people in the web are suggesting to post in the below format: POST: http://example.com/user/login?_format=json Content-type: application/json Data:...
0
votes
1answer
16 views

Changing the html and order of system fields(pass/email/locale/etc) of user edit form

I have changed a number of forms accessible by users to fit a certain style. To do this I used an #after_build function that adds prefixes and suffixes to fields, as well as a bit of javascript. This ...
1
vote
0answers
29 views

Delete user in transaction

I'm having trouble figuring out why the following code isn't working in Drupal 7. _queue_processor is a cron queue processor function: function _queue_processor($uid) { $transaction = ...
0
votes
0answers
27 views

Undefined property $uid when running update.php

I have had a minor issue which has been popping up whenever I run update.php such as after updating some modules, etc. Anytime I run update.php I get the following error: Notice: Undefined ...
0
votes
1answer
17 views

Prevent login except from Services

I would like to prevent my users to login except for those who login through my REST Service. Is that possible?
0
votes
1answer
34 views

How to grant create and update permissions to a custom role?

I have a new role as "Publisher". I want to grant Publisher 'create' and 'update' permission using code. My .permissions.yml file looks like this : 'delete contact entity': title: Delete entity ...
-2
votes
1answer
30 views

Send welcome email on one time login via admin UI

I am Importing all my users into drupal but I don't want to send the welcome emails now. When the site goes Live I want to be able to push a button or perform an action which sends all the users the ...
0
votes
1answer
55 views

How to modify default login page using theme?

Version: Drupal 8.7.x Currently, I am using a subtheme of the Bootstrap theme and I want to override the default login page because the interface doesn't look good. I was hoping to override the ...
1
vote
1answer
42 views

Unable to run update.php or update modules from web interface

I would really like to be able to install module updates through the web interface or run update.php when needed without changing settings.php, but something seems to be broken in my setup because it ...
0
votes
0answers
38 views

Checkout rule 'Create a new account for an anonymous order' not accepting mobile number field

I am using Mobile Number module to enable OTP verification. Also, with Drupal commerce, I have also enabled anonymous checkout. During the execution of the rule Create a new account for an anonymous ...
0
votes
0answers
29 views

Can't go anywhere from user edit page after login

Having an issue with a certain user that is not reflected on other users, when this particular user is logging in he isn't redirected to homepage or to admin/dashboard but to user/edit page, ...
0
votes
1answer
55 views

Overriding the User entity list_builder handler

I'm trying to override the User entity list_builder handler to add another column to the table and implement some JavaScript search functionality. The code I'm using is below which is in my modules ...
-1
votes
1answer
26 views

User password reset link leads to access denied page

Command: drush uli Output: http://default/user/reset/uid/..../...hash.../login The output URL normally logs you in automatically, but it gets takes to access denied error instead.
1
vote
1answer
259 views

How can I force the user to register/login first before being redirected back to the current URL?

I'm displaying a form using the Form API under a given URL. User gets this URL and accesses it. But before the user fills out the form, they need to be registered or logged in. How can I send the ...
1
vote
0answers
30 views

Checking if user logged-in by external script, fails

With a script on an external webpage (same domain), I need to detect whether the user that's visiting the page is or not logged in. [EDIT] This occurs when the script is into a subfolder. If it's put ...
0
votes
1answer
43 views

How to add Checkbox Fields to User Accounts? [closed]

Is it possible to add multi-choice checkbox fields to a Content Type or the fields of a User Type? Hoping it is possible to create the following when a User is registering for an account. They should ...
0
votes
1answer
47 views

How is the user logout process supposed to work?

I’ve built a complete private site. Everything seems to work. When users wants to log out, they are redirect from /user/logout /user/login?destination=/, which seems the normal behavior, for what I ...
0
votes
1answer
13 views

hook_custom_theme() works except if a user submits a user form with mismatched passwords. Then they get served the admin theme

Title basically. My hook_custom_theme() has been working for ages and I only just realised the admin theme is being served for an error when saving a user form ie. mismatched passwords. A snippet ...
0
votes
0answers
31 views

Is it possible to execute a function on a user object in Twig?

You can use hook_entity_load to add fields to the user object like so: function mymodule_entity_load($entities, $type) { if ($type == 'user' ) { foreach($entities as $e) { $e-...