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!
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.
