Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

Based on your responses in the comments, it sounds like you want anonymous users to be sent to the login page on any access and for authenticated users to be able to access the site as normal. You can achieve this with a custom module that checks for logged-in status and redirect to the login page, or via the Require Login Module which does essentially the ...


0

I think this is a bug in Profile2 module. I recreated your issue on a test installation and the same results happened. After I inspected the database itself I found that the machine name was not changed in the table profile but correctly changed in profile_type table. What you could try is to manually change the machine name in the profile table and see ...


0

You can generate the query here & run the query in your database.


0

whats this line is doing? Does it load all active modules in website? It invokes a hook (hook_user_login), which other installed modules can respond to. It doesn't "load" any modules, but those other installed modules are already available at that point, yes. Could I remove this line? Physically, yes, but it would be a terrible idea. It's important, or ...


0

A little surprised how easy this was to fix; but it seems to be working. Console originally created permissions similar to what @esefwan posted and in MyEntityAccessConrtolHandler.php it created this code: protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { /** @var \Drupal\reserve\Entity\MyEntityInterface ...


0

You're probably looking for the username theme: $variables['userName'] = [ '#theme' => 'username', '#account' => $account, ];


0

Drupal 8 In Drupal 8, you can try using the rabbit_hole module. Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page.


0

Similar to the original posting requirements above, I required something similar, but used a Rules Link created Bootstrap Button situated on a Node page to which then redirected the Action Rule to the Message page and used the following syntax to autocomplete the Recipient field fill of both the message and the said Subject: messages/new/?edit[recipient]=[...


0

When the access to a route doesn't depend uniquely on a single permission, you need to implement what Access checking on routes describes. Implement a service tagged access_check Associate it with the route Since you are altering the route defined from another module, you need to also follow Altering existing routes and adding new routes based on dynamic ...


3

You can filter the fields by checking which interface the field implements: $fields = array_filter( \Drupal::service('entity_field.manager')->getFieldDefinitions('user', 'user'), function ($fieldDefinition) { return $fieldDefinition instanceof \Drupal\field\FieldConfigInterface; } ); The second parameter of getFieldDefinitions() is the bundle. ...


1

It sounds like you should start with what you don't want. Drupal::currentUser()->id() will retrieve the current user's UID. From there, you can use the UserStorage::loadByProperties() method you referenced to pull the UID by user name. The last step is add code to check Drupal::currentUser()->id() doesn't match the UID found from UserStorage::...


1

There are several ways to get the user's name programmatically $account = \Drupal\user\Entity\User::load(1); // pass your uid //1 drupal_set_message($account->name->value); //2 drupal_set_message($account->get("name")->value); //3 drupal_set_message($account->getUsername()); //4 drupal_set_message($account->name->getValue()[...


0

You can use Android AccountManager over https to be more secure. Like this Drupal 8 Android app at https://github.com/onedrupal/One-Drupal-Android.


0

Eyosiyas Tadele, Like 4k4 said, You don't even need to write any PHP code, not even single file and definitely not a module if you are using Drupal 8 core REST module. Here is a sample Drupal 8 Android app https://github.com/onedrupal/One-Drupal-Android that uses core REST API to POST node. Similarly you can POST to user registration API. You can use https:...


1

Elie Masaad, You can use PATCH method like this Drupal 8 Android app at https://github.com/onedrupal/One-Drupal-Android. PATCH related android source code using OkHttpClient https://github.com/onedrupal/One-Drupal-Android/blob/master/app/src/main/java/com/technikh/onedrupal/activities/ActivityPost.java#L637 request = new Request.Builder() ...


1

By default, drupal_set_message() is set and displayed on form submission when a new password is emailed. It's possible LoginToboggan is interfering with this but I haven't encountered that in my use of it. Alternatively, if you cannot resolve the issue, you can use hook_form_alter() to create your own submission handler on the password reset form, and use ...


0

You can make your content field a taxonomy term and you can accomplish this with a simple view without any custom coding. If we assume vocabulary Departments user has field Departments some users with department selected token and views_argument_token installed Add a content view Add any relevant filters (content types, etc) Add user relationship Add ...


0

You can get the username & email of the current logged in user like so: function tropical_preprocess_page(&$variables){ # gets current username $user_logged_in_name = $variables['user']->getDisplayName(); # Capitalize first letter $variables['user_logged_in_name'] = ucfirst($user_logged_in_name); # gets User Email $user_email = $...


Top 50 recent answers are included