I’ve altered it to the following but it is still not working, however it is not returning an error anymore. I think maybe it is not finding the root password field? Any ideas why?
add_filter(‘acf/validate_value/name=root_password’, ‘root_password’, 10, 4);
function root_password($valid, $value, $field, $input_name) {
if ($valid !== true) {
return $valid;
}
if (strlen($value) < 8 // < 8 characters
|| preg_match(‘/^[A-Z]/’, $value) // starts with a cap
|| !preg_match(‘/[A-Z]/’, $value) // contains no caps
|| !preg_match(‘/[0-9]/’, $value) // contains no numbers
|| !preg_match(‘/[0-9a-zA-Z]$/’, $value) // ends is something other than a letter or number
) {
$valid = ‘Value is not valid’;
}
return $valid;
}
Thanks!
I saved this in the functions.php file but it does not seem to work. I just added a product to the cart with a password that doesn’t match the parameters and it went through.
Is there anything else that may be causing an issue?
Thank you very much for your help so far. I really appreciate it.
Regards,
Jamie
Hi John,
Thank you very much for the help!
I am getting an error on the following line: || !preg_match(‘/[0-9a-zA-Z]$/’, $value) // ends is something other than a letter or number) {
$valid = ‘Value is not valid’;
“Your PHP code changes were rolled back due to an error on line 224 of file wp-content/themes/hestia-pro/functions.php. Please fix and try saving again.
syntax error, unexpected ‘a’ (T_STRING), expecting ‘]'”