I wrote the following function using entity_create, but I am getting an error 'call to undefined function'. Is there anything I need to load so that I can use Entity API for my module? I have Entity API already installed but it seems that it is not globally accessible. What I would be missing to have entity_create or other Entity API functions available?

function customisation_add_newsnap($title, $id, $name, $hash, $datetime, $type) {
  $values = array(
    'type' => 'enews_snapshot',
    'uid' => 6,
    'status' => 1,
    'comment' => 0,
    'promote' => 0
  $entity = entity_create('node', $values);

  $ewrapper = entity_metadata_wrapper('node', $entity);



  $my_date = new DateTime('January 1, 2013');

  $entity->field_es_postdate[LANGUAGE_NONE][0] = array(
    'value' => date_format($my_date, 'Y-m-d'),
    'timezone' => 'UTC',
    'timezone_db' => 'UTC',


  //entity_save('node', $entity);   
  • Are you sure that the Entity API module is enabled? – Елин Й. Nov 6 '13 at 18:28
  • how are you calling this function ? drush php-script your-script.php ? Is drupal fully bootstrapped ? – tenken Nov 6 '13 at 19:13
  • Entity API is enabled,and i believe so it is fully bootstrapped. – axscode Nov 7 '13 at 23:27

Your Answer

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

Browse other questions tagged or ask your own question.