PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

gform_after_submission hook and accessing data submitted through a List field

  1. shaunhd
    Member

    Hello,

    I have a form which includes a list field to gather a group of friend's email addresses.

    I'm then hoping to use the gform_after_submission hook to send an email to each address submitted through the field.

    If the list field has an ID of 2 then I can grab the data submitted through the list field in my hook by using:

    $friends_emails = $entry['2'];

    But this gives me something like the following:

    a:4:{i:0;s:23:"person1@email.com";i:1;s:23:"person2@email.com";i:2;s:23:"person3@email.com";i:3;s:23:"person4@email.com";}

    What is the pattern and so what would be the syntax for me to grab the email addresses out of this string?

    Many thanks for your help,
    Shaun

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  2. David Peralty

    It is a serialized array, and the values you need should come every third. You can use PHP to deal with the semi-colon delimited way that it is presented and pull out the e-mail addresses you want.

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  3. shaunhd
    Member

    Thanks David,

    I should have spotted that myself. All I need do is unserialize() the string to create an array with elements made up of the email addresses submitted through the form's list field. Perfect!

    Thanks for your help,
    Shaun

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink

This topic has been resolved and has been closed to new replies.