6101 comments
2357 subscribers
6266 on Twitter
Subscribe! Feed reader E-mail

June 2, 2008

Bulk view

Drupal makes me feel like Bruce Lee + Jackie Chan

Fast. Powerful. And having a heck of a lot of fun.

Short URL: http://sachachua.com/blog/p/4912

Drupal: Storing data in the user profile

If you want to store data in the user profile, here’s an example of a quick and dirty way to do it:

global $user;
if ($user) {
  $array = array('fieldname' => 'value_to_save');
  user_save($user, $array);
}

Then access it with $user->fieldname. For more configurability, check out the Profile module.

Short URL: http://sachachua.com/blog/p/4911

Drupal: Adding lines to settings.php in an installation profile

Installation profiles can make it easier for you to test and reproduce your configuration. But what if you need to do more than what Install Profile Wizard detects? For example, parts of the Domain Access module ask you to add lines to your sites/default/settings.php. Fortunately, PHP allows you to set up your install profile to write to files during installation.

Here’s the code I added to the end of the profilename_profile_final() function:

    // Add the following to the end of settings.php
    $file = fopen("sites/default/settings.php", "a");
    if ($file) {
      fputs($file, "\$cookie_domain = '.transitions2.org';\n");
      fputs($file, "require_once './sites/all/modules/domain/domain_conf/settings_domain_conf.inc';\n");
      fputs($file, "require_once './sites/all/modules/domain/domain_prefix/settings_domain_prefix.inc';\n");
      fclose($file);
    } else {
      drupal_set_message("Can't add domain-related lines to sites/default/settings.php");
    }

Hope it helps!

Short URL: http://sachachua.com/blog/p/4910

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!