I am trying to understand about how setting variables works in install profiles. As an example, how would I set the option to enable people to create a website for the account in the install profile? Here is the page on variable_set https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/variable_set but how do I retrieve the value.

  • You don't know how to set variables in profile, which one to set, or how to retrieve it?
    – Mołot
    Commented Jul 1, 2013 at 11:27
  • I don't know how to set, or how to find out which one to set. Commented Jul 1, 2013 at 11:43

2 Answers 2


Variables in install profiles work no differently to variables in a 'normal' bootstrap.

To set a variable use variable_set():

variable_set('var_name', 'value');

To retrieve it, use variable_get():

$var = variable_get('var_name', 'default');

To find the names of variables, the easiest method is to install the Devel module and visit the variable editor at /devel/variable

  • How do you know what the var_name is ? Commented Jul 1, 2013 at 12:13
  • @AndrewWelch Just updated the answer - you either need to check the variables table (which you can do through the UI with Devel), or go through the code for the various admin forms that set those variables to find the name(s).
    – Clive
    Commented Jul 1, 2013 at 12:15

Users can register at your Drupal 7 site by default but you have to disable that. If you want to do this, just put following in your profile.install file:

// Only administrators can create user accounts.
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);

It would make sense to copy the standard installation profile to have a good base and then you just could add these two lines from above :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.