function _captcha_get_error_message in CAPTCHA 7
Same name and namespace in other branches
- 8 captcha.inc \_captcha_get_error_message()
Get the error message as configured on the general CAPTCHA settings page.
If the locale module is enabled, the error message will be returned for the current language the page is rendered for. This language can optionally been overridden with the $lang_code argument.
Parameters
string|null $lang_code: an optional language code to get the description for.
Return value
string String with (localized) error message.
2 calls to _captcha_get_error_message()
- captcha_admin_settings in ./
captcha.admin.inc - Form builder function for the general CAPTCHA configuration.
- captcha_validate in ./
captcha.module - CAPTCHA validation handler.
File
- ./
captcha.inc, line 282 - General CAPTCHA functionality and helper functions.
Code
function _captcha_get_error_message($lang_code = NULL) {
// If no language code is given: use the language of the current page.
global $language;
$lang_code = isset($lang_code) ? $lang_code : $language->language;
// The hardcoded but localizable default.
$default = t('The answer you entered for the CAPTCHA was not correct.', array(), array(
'langcode' => $lang_code,
));
// Look up the configured error message or fall back on the (localized) default.
if (module_exists('locale')) {
$message = variable_get('captcha_error_message_' . $lang_code, $default);
}
else {
$message = variable_get('captcha_error_message', $default);
}
return filter_xss_admin($message);
}