在贡献模块(ldap_sso.module)中,正在声明自定义drupal_set_message。
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');
如何覆盖此消息或可能通过我的自定义模块取消设置,以便在LDAP SSO身份验证失败时根本不会调用它?
答案 0 :(得分:1)
如果你在https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_set_message/7查看drupal_set_message()的代码,你会注意到只有当$ message参数不为null时才会设置一条消息。因此,如果我们以某种方式将$ message参数设置为NULL,则不会设置任何消息。
幸运的是,由于LDAP模块使用的是主题功能,因此这很容易。在您正在使用的主题的template.php文件中定义主题函数。假设您使用的是名为“mytheme”的主题。然后打开该文件夹中的template.php文件并添加以下代码:
/**
* Implements theme_ldap_authentication_message_not_authenticated().
*/
function mytheme_ldap_authentication_message_not_authenticated(&$vars) {
return NULL;
}
清除缓存。现在主题('ldap_authentication_message_not_authenticated',...)将调用您已定义的主题函数,而不是LDAP模块定义的主题函数。由于您的主题函数返回NULL,因此不会设置消息。
Neerav Mehta