1

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 Jul 1 '13 at 11:27
  • I don't know how to set, or how to find out which one to set. – Andrew Welch Jul 1 '13 at 11:43
4

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 ? – Andrew Welch Jul 1 '13 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 Jul 1 '13 at 12:15
1

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, privacy policy and cookie policy

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