what's the best way to go about to hacking core variables? I need to edit a few values in Drupal core's common.inc, for instance:

  'name' => 'Generator',
  'content' => 'Drupal ' . $version . ' (http://drupal.org)',

and also in user.pages.inc

$timeout = variable_get('user_password_reset_timeout', 86400);

but if I update drupal core, these values will return. Is there a "Drupal way" of editing these values so that I don't have to do that every time?


  • 2
    Hacking the core is never a good idea.
    – nit3ch
    May 7 '13 at 16:43

You should not edit core code, ever.

For variables (set with variable_set) can try using something like strongarm module, or you can override using $conf in settings.php:

 * Variable overrides:
 * To override specific entries in the 'variable' table for this site,
 * set them here. You usually don't need to use this feature. This is
 * useful in a configuration file for a vhost or directory, rather than
 * the default settings.php. Any configuration setting from the 'variable'
 * table can be given a new value. Note that any values you provide in
 * these variable overrides will not be modifiable from the Drupal
 * administration interface.
 * The following overrides are examples:
 * - site_name: Defines the site's name.
 * - theme_default: Defines the default theme for this site.
 * - anonymous: Defines the human-readable name of anonymous users.
 * Remove the leading hash signs to enable.
 $conf['site_name'] = 'My Drupal site';
 $conf['theme_default'] = 'garland';
 $conf['anonymous'] = 'Visitor';

This documentation is from default.settings.php.


To your first question, you can change the meta tag like this inside template.php

function YOURTHEME_html_head_alter(&$head_elements) {
  $head_elements['system_meta_generator']['#attributes']['content']= // whatever you want

To the second, you could create a form that changes the variable along these lines:

function YOURMODULE_admin_settings_form() {


  $form['user_password_reset_timeout'] = array(
    '#type' => 'textfield',
    '#title' => t('User Password Reset Timeout'),
    '#default_value' => variable_get('user_password_reset_timeout', 86400),
    '#size' => 28,
    '#maxlength' => 8,
    '#description' => t('Enter the number of seconds for the user password reset timeout'),

  return system_settings_form($form);


and then use that in a menu:

function YOURMODULE_menu() {


  $items['admin/settings/YOURMODULE'] = array(
    'title' => 'YOURMODULE Admininstration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('YOURMODULE_admin_settings_form'),
    'access callback' => 'user_access',
    'access arguments' => array('APPROPRIATE_PERMISSION_ON_YOUR_SYSTEM'),

  // other menu items go here

  return $items;

  • Thanks for the responses guys. I ended up using the metatag plugin to edit the generator tags, and built a plugin to extend the time in seconds. How to here: drupal.org/node/801280
    – d_f
    May 10 '13 at 15:58

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.