1

I'm working on a version of CiviCRM installed in Joomla, I'm using a registration form with custom fields of Civi for the registration. The problem is that CiviCRM does not apply the same checks on passwords as Joomla does. I have not found solutions in the system, so I'm trying to insert custom controls using hooks. As indicated I created a file and specified the path and customize the code find on CiviCRM guide for my purpose, but does not detect any changes on the form I'm using.

function joomla_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors ) {
  if ($formName == 'Edit') {
    foreach ($fields['cms_pass'] as $key => $password) {
      if(strlen(trim($password)) > 8) {
        $errors['cms_pass[' . $key . ']'] = ts('Password must be 8 characters');
      }
    }
  }
  return;
}
  • CiviCRM uses the CMS for managing users and passwords so it is not managing passwords separately from Joomla. Can you explain a bit more about your form, how it is being called and where it appears Civi is not checking the password? – Aidan Nov 29 '18 at 14:56
  • Hello. I am using the form "Name and adress" (default in CIVI) with "Account creation required " active, but, the password field don't do any of the Joomla control – Ictadmin Nov 30 '18 at 11:59
1

Ok, I found an example on the Civi Wiki and, with a bit of workaround, it finally works:

function joomla_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {  

  $errors = array();

  // check we're targeting the right form
  if ($formName == 'Edit') {
    return true;
  }

   $password = CRM_Utils_Array::value( 'cms_pass', $fields );

   // ensure that password is present and valid
   if (!$password) {
      $errors['cms_pass'] = ts( 'Password is a required field' );
   } elseif (strlen($password) < 50) {
      $errors['cms_pass'] = ts( 'Password must be longer than 50 characters');
   }

  return empty($errors) ? true : $errors;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.