drupal snippets

I'm a big fan of fighting with Drupal's inefficiencies and bottlenecks. Most of these come from contrib modules. Everytime we install a contrib module we should be ready for surprises which come on board with the module.

There are loads of modules that can do this for you, but why to install one more module if you can do this with one string of code? The best thing is that approach below does a redirection even if you login from user login block.


Just put the following code into your custom module:

/**
 * Implements hook_user_login().
 */
function module_name_user_login(&$edit, $account) {
  // Don't redirect on password reset.
  $current_menu_item = menu_get_item();
  if ($current_menu_item['path'] == 'user/reset/%/%/%') {
    return;
  }
  // Redirect user to profile page after the login.
  $_GET['destination'] = 'user';
}

You can find this snippet at dropbucket.org here: http://dropbucket.org/node/746
UPDATE 03/08/2013: Added several lines to prevent redirection during password reset.

Hi everyone, hope some of you had/having a great time at DrupalCon Portland. Since I could go I decided to do something useful and apply to Dropbucket Drupal Snippets Repository some new ideas I had in my mind. Long story short, last night I rolled out an update which brought the follwing:

Yes, you read it right! Now you can create personal lists of Drupal snippets at Dropbucket.org - Drupal snippets repository. It turned out that we already have loads of great snippets at the website and there challenge have appeared: how to group these snippets in some convenient way? So for example, you found five cool snippets about theming and you could add them to your bookmarks, but later, you can lose track of them because you're constantly adding other snippets to your bookmarks and sooner or later you can simply get lost in your bookmarks feed.

Today I want to share with you 8 great Drupal snippets that blew my mind. I found these browsing Dropbucket.org - Drupal snippets repository. There are lots of cool Drupal snippets being shared and stored at dropbucket.org but I found these to be the most new and interesting to me. I do really wish I knew about before. But Drupal is full of surprises and there are loads of tricks which don't know about, even if you've spent lots of years working with The Big Drop :) Okay, let's start. Snippets aren't sorted in any order of preference:

A week ago I've announced a project which I created in order to fullfill my own need of storing Drupal snippets - Dropbucket.org. I've announced this project here on my blog and it turned out to be a huge success attracting lots of eyes, positive responses, thanks, clicks, tweets and registrations. I'm really amazed by reactions I received and today I decided to sum up the first week of life of the Dropbucket.org.

Dropbucket - Drupal snippets storage

I've been doing Drupal for last six or seven years and tried lots of ways of storing snippets. I used internal capabilities of IDE's (like snippets in Eclipse or code templates in Netbeans), I stored them in notepad, evernote, used lots of different downloadable snippet managers and stuff.

But there always were two needs which I couldn't satisfy with these approaches: I wanted snippets to be stored online (so I didn't lost them when I format my HDD or uninstall IDE) and I wanted to share my drupal snippets in a dedicated place, where drupalers gather.

We Drupal people, we love to share, this is in our blood and this is an underlying power which drives Drupal community, do something and share with others! So why not to share with our snippets? I believe every of us has loads of different chunks of code which we use on a daily basis, we need to store them, we need to share them. That's why I created dropbucket.org - Drupal snippets repository, a place where you can put your little drops of drupal code and fill the snippet bucket.

Subscribe to drupal snippets

You are here