0

can you please help me to add a custom error to Postfixadmin. In the config.local.php file I add the following to $CONF['password_validation'] = array()

'/([-#*.!@$%^&(){}:;<>,.?~_+=|].*){1}/' => 'x_no_special',

Regexp works ok, now I want to add a description of the error. I do it like according to the manual, I add after the array:

$CONF['language_hook'] = 'x_no_special';
$PALANG['x_no_special'] = "123"; 

But no error is not showing. If I directly add $PALANG['x_no_special'] = "123" to /languages/en.lang then everything is ok

My config file looks like:

<?php
$CONF['password_validation'] = array(
    '/.{8}/'                => 'password_too_short 8',      # minimum length 5 characters
    '/([a-zA-Z].*){3}/'     => 'password_no_characters 3',  # must contain at least 3 characters
    '/([0-9].*){2}/'        => 'password_no_digits 2',      # must contain at least 2 digits
    '/([-#*.!@$%^&(){}:;<>,.?~_+=|].*){1}/' => 'x_no_special', #CUSTOM must contain at least 1 special character
);
$CONF['language_hook'] = 'x_no_special';
$PALANG['x_no_special'] = "123";
?>
cozby
  • 7
  • 3

1 Answers1

-1
$CONF['language_hook'] = 'x_password_no_special';

function x_password_no_special($PALANG, $language) {
$PALANG['x_password_no_special'] = '123';

return $PALANG;
}
cozby
  • 7
  • 3
  • Can you add some text to explain why this is the solution? This would help others with the same problem to understand your Q&A here. – allo Feb 12 '23 at 12:36
  • 1
    If you want to make a description of the error without editing /lang/*.lang (which is what you should do) Then this is supposed to be done through $CONF['language_hook'], it waits for the name of the function, which we will describe below – cozby Feb 13 '23 at 06:48
  • You can edit the answer to include the explanation, so it is a full solution. And after 2 days you can then accept your own answer, so the Q&A pair will help others with the problem. – allo Feb 13 '23 at 09:53