Custom permissions in Drupal 8

Sat, 17/09/2016 - 14:31

Drupal's permissions system is at the same time easy to use and very powerful. It covers most of the cases where your module provides different functionality for various roles on the site.

In both versions of Drupal this is fairly straightforward to implement through code. There are two parts to this article: defining custom permissions (both static and dynamic), and performing checks to see if the current user has access to them.

Quick tip: getting the SQL built with db_select() in Drupal 7 and Drupal 8

Fri, 02/09/2016 - 15:03

When building more complex queries using db_select() you will often want to see the exact SQL being generated. This is helpful for understanding the query or simply debugging the results.

This article will show you how to see the exact query being generated with db_select() as well as getting how to get all values passed as arguments. The code in this article will be applicable for both Drupal 7 and Drupal 8.

Changing user display name in Drupal 7 and Drupal 8

Wed, 31/08/2016 - 21:15

Every website that displays user information on the front end will use profile fields such as first and last names for representing the members. By default Drupal shows only the username, which is definitely something you will want to change.

Modifying this is relatively simple. You could always choose which fields to use in Views, Rules and other modules, but the main problem is maintenance - the setup will be spread across many different pages and it's not the most optimal solution in the long run.

The right way is to change the way user display names are formatted by the system itself. This article will show you how to manage this for both Drupal 7 and Drupal 8 in your custom code.

Keeping code on GitHub and

Mon, 22/08/2016 - 13:30 encourages developers to host all of their Drupal-related Open Source code directly on This is great, because all your OS code will be associated with your account and you will get a lot of extra features such as issue tracking, release publishing, ability to reference other issues and so on. However, current interface of website is not the most user friendly, especially when you want to have a quick look at the code of a contrib module.

That's where platforms such as Github, Gitlab, BitBucket and others can be helpful.

Subscribe to Drupal Planet