Getting form values

This guide will explain how to get access to any submitted form data inside action or filter hook functions. These functions are usually used to modify the behaviour of the plugin or perform custom actions.

Get a single form value

1. Get your unique Quform element ID for the form element using this guide.

2. Inside the Quform hook PHP function you can use the following code, then replace iphorm_X_X with the unique element ID from Step 1.

1
$value = $form->getValue('iphorm_X_X');
$value = $form->getValue('iphorm_X_X');

$value now contains the submitted form value for element iphorm_X_X

Get all form values

To get all form values use the code below.

1
$values = $form->getValues();
$values = $form->getValues();

$values now contains all the submitted form values in an associative array. The element unique ID is the array key and the submitted value is the array value. Below is an example of the contents of $values after a form has been submitted.

1
2
3
4
array(
    'iphorm_1_1' => 'My Name',
    'iphorm_1_2' => 'me@example.com'
)
array(
    'iphorm_1_1' => 'My Name',
    'iphorm_1_2' => 'me@example.com'
)

Data types of the form values

The data types of the form values may vary depending on the type of the element. In the table below the data type for each each element and an example are shown.

Element Type Example
Single Line Text string ‘Foo’
Paragraph Text string ‘Foo’
Email Address string ’email@example.com’
Dropdown Menu string ‘Foo’
Checkboxes array
array(
    0 => 'Chosen Option 1',
    1 => 'Chosen Option 2'
)
Multiple Choice string ‘Foo’
File Upload array
array(
    0 => array(
        'url' => 'http://www.example.com/path/to/the/file.jpg',
        'text' => 'file.jpg',
        'fullPath' => '/home/example.com/public_html/path/to/the/file.jpg'
    ),
    1 => array(
        'url' => 'http://www.example.com/path/to/the/second-upload.jpg',
        'text' => 'second-upload.jpg',
        'fullPath' => '/home/example.com/public_html/path/to/the/second-upload.jpg'
    )
)
Date array
array(
    'day' => '23',
    'month' => '11',
    'year' => '2012'
)
Time array
array(
    'hour' => '11',
    'minute' => '58',
    'ampm' => 'pm'
)
Hidden string ‘Foo’
Password string ‘Foo’

Still having trouble? Head over to the forums.

Forums