You are here

function entityform_user_previous_submission in Entityform 7.2

Same name and namespace in other branches
  1. 7 entityform.module \entityform_user_previous_submission()

Get previous submission for a form for a user

Parameters

string $type:

int $uid:

int $draft:

Return value

NULL|Ambigous <A, mixed>

2 calls to entityform_user_previous_submission()
entityform_form_wrapper in ./entityform.admin.inc
Form callback wrapper: create or edit a entityform.
entityform_user_draft in ./entityform.module
Get the current draft submission if any for a user

File

./entityform.module, line 465
Module for the Entityform Entity - a starting point to create your own Entity and associated administration interface

Code

function entityform_user_previous_submission($type, $uid = NULL, $draft = 0) {
  $submission = NULL;
  if (!$uid) {
    global $user;
    $uid = $user->uid;
  }
  if ($uid) {
    $submissions = entityform_get_submissions($type, $uid, $draft, 1);
    $submission = array_shift($submissions);
    if ($submission) {
      $submission = entityform_load($submission->entityform_id);
    }
  }
  $context = array(
    'draft' => $draft,
    'uid' => $uid,
  );
  drupal_alter('entityform_previous_submission', $submission, $type, $context);
  return $submission;
}