1
votes

In the contributed module (ldap_sso.module) a custom drupal_set_message is being declared.

drupal_set_message(theme('ldap_authentication_message_not_authenticated',
  array('message' =>
  t('You were not authenticated by the server.
  You may log in with your credentials below.')
  )
  ), 'error');

How can i override this message or possible unset it via my custom module so it doesn't get called at all when LDAP SSO authentication fails?

1
Could this be accomplished in settings.php? $conf['locale_custom_strings_en']['You were not authenticated by the server.You may log in with your credentials below.'] = 'Error removed by admin';Emir Memic

1 Answers

1
votes

If you look at the code of drupal_set_message() at https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_set_message/7, you will notice that a message gets set only if the $message parameter is not null. So if we somehow set the $message parameter to be NULL, then no message will be set.

Fortunately since the LDAP module is using a theme function, this is easy. Define a theme function in the template.php file of the theme that you are using. Suppose you are using a theme called "mytheme". Then open the template.php file in that folder and add the following code:

/**
 * Implements theme_ldap_authentication_message_not_authenticated().
 */
function mytheme_ldap_authentication_message_not_authenticated(&$vars) {
  return NULL;
}

Clear the cache. Now theme('ldap_authentication_message_not_authenticated', …) will call the theme function that you have defined rather than the one defined by the LDAP module. Since your theme functions returns NULL, message will not be set.

Neerav Mehta

Drupal development in Bay Area