1

I've got a view where I approve webform submissions, update a table column programmatically and send out e-mails through its tpl file. However, somehow I'm getting wrong and $uid and therefore e-mails go out to the wrong people.

I tried to debug this using dpm(), that's how I know I'm getting wrong values. I first thought I am setting variables in the wrong place but I doubt that because it's the same even though I changed the lines. Can you help me? Below are my codes for setting variables and sending out e-mails:

<?php

if(isset($approve))
{
  $uid=$submission->uid;
  $nid=$submission->nid;
  $sid=$_POST['sid'];
  $sponsorid=$_POST['sponsoruid']; 
  dpm("uid:".$uid);
  dpm("nid:".$nid);
  dpm("sid:".$sid);
  dpm("spid:".$sponsorid);
  if (empty($sponsorid))
  {
    $sponsorid=0;  
  }
  $url="/proje-basvurulari";
  $num_updated = db_update('webform_submissions') 
    ->fields(
      array(
        'approval' => '2',
        'sponsorid'=>$sponsorid,
      ))
      ->condition('sid', $sid, '=')
      ->execute();

  $date=date('d-m-Y', $submission->submitted);
  $fdetails = db_query("select * from {users} where uid=$uid")->fetchAll();
  $sdetails = db_query("select * from {users} where uid=$sponsorid")->fetchAll();
  dd($fdetails);
  dd($sdetails);


  foreach($sdetails as $s) {
    $semail=$s->mail;
    $sname=$s->name;
  }
  foreach($fdetails as $f)
  {
    #$femail=$f->mail;
    $fname=$f->name;
  }
  $femail = $submission->data['4']['0'];
  ...
  ?>

$uid and therefore $fdetails are set wrong. Isn't $submission->uid supposed to be the uid of whoever filled out the webform?

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.