Update Webform through automatic Cron

Created on 20 July 2019, almost 5 years ago
Updated 23 March 2023, over 1 year ago

Hi,
I'm trying to send email to my registered users end of the who is not paid. So that I created a hook_cron, In that trying to Load all submissions of the specific webform using entityQuery.

And then based on a field status trying to send an email to user then change the status of the field. In this case, I can able to run this cron manually, But while running through automatic cron it doesn't work.

What I understand is automatic cron will run as an anonymous user, So it couldn't load webform submissions. If I'm right Please help me to find out the right way to load all webform submissions and update it later. Please check the sample code below. thank you in advance.

$query = \Drupal::entityQuery('webform_submission')
    ->condition('webform_id', 'example_webform_name');
  $result = $query->execute();
  $storage = \Drupal::entityTypeManager()->getStorage('webform_submission');
  $submissions = $storage->loadMultiple($result);
  $submission_data = array();

  foreach ($submissions as $submission) {
    $submission_data[] = $submission->getData();
  }

 foreach ($submission_data as $data) 
  {
//rest of functions.
  }


📌 Task
Status

Closed: works as designed

Version

6.1

Component

Code

Created by

🇮🇳India KarthickAcsh_R coimbatore

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024