I'm wondering how we can change, via code, the Name and Description for a content type that is provided by a contrib module (in this case, the "User Alert" content type provided by the user_alert module).

I know I can change this manually by going to Admin > Structure > Content types and editing the Name and Description there, but I'd prefer to do this programmatically in code so that I can automatically deploy it to staging and production sites.

In the user_alert module, the original Name/Description details are:

function user_alert_node_info() {
  return array(
    'user_alert' => array(
      'name' => t('User Alert'),
      'base' => 'user_alert',
      'description' => t('A User Alert is a short Twitter like message displayed at the top of the site, alerting users to critical information like an online sale, new blog post, or breaking news. After viewing it, they can click and close the message.'),
      'has_title' => TRUE,
      'title_label' => t('Title'),
      'disabled' => FALSE,

I would've guessed that there would be a hook_node_info_alter to change this, but it seems such a thing does not exist. Is the answer to use hook_entity_info_alter? If so, what is the correct code to use?

I have tried putting this in my custom feature slnsw_newsflash.module file:

    function slnsw_newsflash_entity_info_alter(&$entity_info) {
      $entity_info['user_alert'] = array(
          'name' => t('Newsflash'),
          'base' => 'user_alert',
          'description' => t('A Newsflash item appears near the top of the page to alert users to urgent notices such as catalogue outages or changed opening hours etc. Utilises the user_alert module.'),
          'has_title' => TRUE,
          'title_label' => t('Admin Title'),
          'disabled' => FALSE,

But it seems to have no effect (after disabling and enabling the slnsw_newsflash features module and running drush cc all/drush rr), so obviously I'm doing something wrong.

I also thought that Features or Strongarm would let you store and save the Name and Description values for a content type provided by a contrib module, but that does not seem to be the case.

  • Can you try this by un-installing module and then againg re-install the same module. This will change the DB record. – Rakesh Falke Oct 20 '15 at 10:30
  • First of all, you don't need to change all the attributes with the hook you're using but only the ones you're interested in. Also, have you tried altering your feature's weight to something heavier than the weight of the contributed module? – webmaniac Oct 4 '16 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.