publicForm

display input forms on your public site
function publicForm($public_columns = null, $label = 'Save changes', $thankyou_url = null)
Pods gives you the ability to display input forms on your site. This lets normal users add content to your site.

Parameters

ParameterTypeDetails

$public_columns
ARRAY
An associative array of columns and properties (see examples)

$label
STRING
(optional) the submit button label

$thankyou_url
STRING
(optional) the URL to send user to upon success

Examples

Adding New Pod Items

Just load the pod you want to use, and call the publicForm() function. Unless you specify columns to use, all columns will appear by default.
<?php
$pods = new Pod('pod_name');
$pods->publicForm();
?>

Editing Existing Pod Items

<?php
$pods = new Pod('pod_name', $id_or_slug);
$pods->publicForm();
?>

Customizing which input fields should appear

<?php
$pods = new Pod('pod_name');
$fields = array('name', 'body', 'start_date');
$pods->publicForm($fields);
?>
Each column can optionally be an array of settings. They will override the default settings for the column. Available settings:
  • default
  • hidden
  • label
  • comment
  • input_helper
<?php
$fields = array(
    'name',
    'body',
    'start_date' => array('input_helper' => 'fancy_date_picker'),
    'slug' => array('hidden' => true)
);
?>

Form has Expired errors

This error can happen depending on certain hosting environments, plugin conflicts, or extra page loads. Below is a list of all known causes and their solutions:
  • Your PHP session.save_path is not writeable (check with your host)
  • Your PHP session.gc_maxlifetime needs to be increased (check with your host)
  • You have opened the form more than once at a time (only the latest loaded form will function for security purposes)
  • There is a plugin conflict which is either loading the page an extra time (in CSS, this can happen through an empty url() in certain cases, causing an additional page load which resets the session key for the form)

Using the ID in the Thank You URL

If you need to use the ID in the URL you are sending the user to after they save an item, you can use the below code and modify to fit your needs:
$pods = new Pod('pod_name');
$fields = array('name', 'content');
echo $pods->publicForm($fields, ' Save Item ', '/new-content-posted/?id=" + msg+ "');

Capturing Output

If you need the output of publicForm() in a string for further processing, for example translating the form labels for a multilingual site, the following code will capture the output to a string:
$pods = new Pod('pod_name');
ob_start();
$pods->publicForm();
$out = ob_get_clean();
// Add code here to modify the $out string
echo $out;
Wordpress Cloud Hosting