Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

0

You can use the field_permissions module to set up permissions for fields by user role and then limit access to admin. If you want to limit to one person then set up a separate role and give that role only to one person.


1

Here is my solution I used to migrate old drupal 6 user records to drupal 8. I used entityTypeManager to create user entity. $values = [ 'name' => $data['name'], 'pass' => $data['pass'], 'mail' => $data['mail'], 'init' => $data['init'], 'status' ...


0

user_validate_name() just verifies that: The username isn't empty The username doesn't begin with a space The username doesn't end with a space The username doesn't contain multiple spaces in row The username contains only allowed characters The username isn't too long user_validate_name() isn't helpful to verify the username has not been already used, but ...


2

Yes profile_create() is deprecated. You should use profile2_create() instead. See the profile2.module file: /** * Deprecated. Use profile2_create(). */ function profile_create(array $values) { return new Profile($values); }


0

You can use the following module. Anonymous login Use-case examples 1) You want to restrict your entire site to authenticated users. Simply enter "*" as the only path to redirect and all anonymous traffic will be redirected to the login page. 2) Your website sends out emails that contain links that only authenticated users can reach (edit your account, ...


0

A small addition I would make would be to do a check for UID = 1 like the rest of D7. A little late but hope it might helps some one. function MODULE_user_has_role() { global $user; if ($user->uid == 1) { return TRUE; } $roles = func_get_args(); foreach ($roles as $role) { if (in_array($role, $user->roles)) { return TRUE; } ...


0

There is also the mail_logger module


1

If you're set on scraping this out of the database, you could try looking at the user__roles table that Kevin mentioned in his comment above: mysql> SELECT * FROM user__roles; +--------+---------+-----------+-------------+----------+-------+-----------------+ | bundle | deleted | entity_id | revision_id | langcode | delta | roles_target_id | +--------+---...


0

Your problem is here: "roles" : { "value" : { "host" : "host" } } Instead of "host", which is is role name it should be a number, which is the corresponding role ID (or rid). You need to change this in both places where "host" appears. Apparently you edited that by hand? To be clear, the Rules Conditional module is NOT needed unless you want the "else if" ...


0

Here is a working rule to redirect users to different URL's depending on user role, you will need Rules conditional module to acomplish task, enjoy. { "rules_user_has_logged_in" : { "LABEL" : "user has logged in, redirect based on role", "PLUGIN" : "reaction rule", "OWNER" : "rules", "TAGS" : [ "redirect" ], "REQUIRES" : [ "rules_conditional", "rules" ], "...


1

The callback function used by default on Drupal for the user autocomplete page (user_autocomplete()) always return a maximum of 10 usernames starting with the string it receives as argument. function user_autocomplete($string = '') { $matches = array(); if ($string) { $result = db_select('users')->fields('users', array('name')) ->...


0

In Drupal 8 you can use this for creating a directory if it not exists and set to it default permissions. \Drupal::service('file_system')->prepareDirectory( 'public://hostel_awards/', FileSystemInterface::CREATE_DIRECTORY );


2

You can find the configuration on admin in the /admin/config/people/accounts but if you want to notify the user programmatically without taking care of what is the config you can use _user_mail_notify function. _user_mail_notify documentation


0

Drupal 8 basic_auth module cannot be combined with other Basic Auth solutions. Check this core issue. The Shield module copes witht the question like this.


0

Drupal by default only allows login by Username. Many users expect to login by email. They can use their email to reset password. You can add the ability to login via username and email with Super Login module


Top 50 recent answers are included