1

I've installed entity forms. I have made a form. I would like to fire some code when a user fills out and submits the form I have created. I do not know how to do this. I don't know which hook to use, nor entirely understand how hooks work.

I've done my best to learn php and read the documentation, but I don't understand. I understand that this is likely a very simple question, I have never had any formal computer training, so even the simplest concepts allude me.

1 Answer 1

1

Entityforms are - as the name suggests - stored as entities. So you can hook into hook_entity_insert(), or hook_ENTITY_TYPE_insert(), having the inserted data as parameter (the entity will be an object):

/**
 * Implements hook_entity_insert().
 */
function MYMODULE_entity_insert($entity, $type) {
  if ($type == 'entityform') {
    // Do your stuff here.
  }
}

or

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function MYMODULE_entityform_insert($entityform) {
  // Do your stuff here.
}

You could also utilize rules to define custom actions on submission, as the entityform submission triggers the entityform_submission rule.

1
  • Sir, thank you very much. I'll do my gosh dang best to implement this. Commented Feb 4, 2016 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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