1

When a node is saved, the Location Taxonomize module by default prints a message if terms are created. This message is very confusing for my users so I want to remove it.

I found where the message is being displayed in the module's code:

/**
 * @param $items - an array of items ready to be taxonomized
 */
function location_taxonomize_taxonomize($items, $form, &$form_state) {
  $saved = 0;
  $tids = array();
  foreach ($items as $item) {
    $results = location_taxonomize_process_item($item);
    $saved += $results['saved'];
    $tids = array_merge($tids, $results['tids']);
  }
  if (!empty($tids)) {
    if (location_taxonomize_term_attach_enabled()) {
      location_taxonomize_term_attach($tids, $form, $form_state);
    }
  }
  $msg = t('Location taxonomize: @num new terms saved', array('@num' => $saved));
  drupal_set_message($msg);
  return array("saved" => $saved, "tids" => $tids);
}

Obviously I could just delete the line drupal_set_message($msg); but then I would have to do this every update and I would eventually forget. I'm still learning how to use hooks and I know that hooks can be used to remove form elements but what about status messages? Is it possible to stop the message from being displayed using hooks and if so, could you please give me some pointers about how to go about doing so?

4

I admit to not having used it before but the Disable Messages module looks like it would do the trick:

Gives a site owner options to disable specific messages shown to end users.

Features:

  • Filter out messages that match a full text string exactly.
  • Filter out messages that match a regular expression.
  • Permissions to specifically hide all messages of a given type from any role.
  • Disable all filtering for specific users.
  • Disable all filtering for specific paths.
  • Apply filtering only for specific paths.
  • Debug system to get messages in the HTML without showing it to the end users.

I think a regular expression would probably be best for this particular message (because of the replacement done using t()); something like this should work:

^Location taxonomize: [0-9]+ new terms saved$
  • Thanks, that did it! I needed to install the dev version since the 1.0 version threw off a warning about a nonexistent index upon installation and on every page, but otherwise there were no problems. – Patrick Kenny May 25 '12 at 12:32

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.