Hi @spelcheck, how did you make it work in the end?
We are having the same problem: we need to drag values from one field from another.
Problem solved, my bad, I don't need "contact" module auto-reply, I just have to create a new instance of email for contact emails and set this parameters so that they do the same as auto-reply:
Recipient type: The submitter of the form
Sorry, my bad, this code belongs to contact_emails module, not to this one, although it is affecting this one. I already created a ticket for contact_emails: https://www.drupal.org/project/contact_emails/issues/3358232 🐛 Contact form auto-reply disabled when contact email available Active
luli_schnauzer → created an issue.
I have the same problem, and I think it has to do with this piece of code:
/**
* Implements hook_mail_alter().
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
function contact_emails_mail_alter(&$message) {
// If an email from the contact module, disable sending.
$contact_form_ids = [
'contact_page_autoreply',
'contact_page_mail',
];
if (in_array($message['id'], $contact_form_ids)) {
/** @var \Drupal\contact\MessageInterface $contact_message */
if ($contact_message = $message['params']['contact_message']) {
$contact_form = $contact_message->getContactForm();
$contact_form_id = $contact_form->id();
/** @var \Drupal\contact_emails\ContactEmailStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage('contact_email');
if ($storage->hasContactEmails($contact_form_id)) {
// Disable sending of default mails if we have at least one email
// set by contact_emails (regardless of whether or not it is a disabled
// email).
$message['send'] = FALSE;
}
}
else {
// If we don't have a contact_message object, something must have gone
// wrong, let's disable just in case.
$log = t('Unable to load the contact message when attempting to alter the default mailing from contact form for contact form id: @contact_form_id', ['@contact_form_id' => $message['id']]);
\Drupal::logger('contact_emails')->notice($log);
$message['send'] = FALSE;
}
}
Located in web/modules/contrib/contact_emails/contact_emails.module. It says "disable sending of default emails of we have at least one email set by contact emails".
So when I have a contact email entry here: /admin/structure/contact/manage/contact/emails
It does not matter if I fill the auto-reply in /admin/structure/contact/manage/contact.
But when I delete all emails in /admin/structure/contact/manage/contact/emails, auto-reply does work.