How to Mark CiviCRM checkbox field not required programmatically?
You can use validateForm hook to empty the errors on the input field. Eg

function hook_civicrm_validateForm($formName, &amp;$fields, &amp;$files, &amp;$form, &amp;$errors) {
  if (your_condition_statement) {
    $form-&gt;setElementError('field_id', NULL);
  }
}


Also note that as this looks like a custom field, civi also provides a UI setting to disable the required attribute. Screenshot from Add/Edit custom field form.