Implementation of Pods API in an external PHP file
hey guys i wanted to use PODS functions in an external PHP file, so i included the blog-header.php & the functions are accessible, so i tried doin an insert to test out the API save_pod_item method but i got an error could you please help me with this
<?php
include 'wp-blog-header.php';
$api = new PodAPI();
$params = array('datatype' => 'deal', 'columns' => array('test_views_day' => '500', 'test_views_dates' => '6-7-2010'));
// create the item
$person_id = $api->save_pod_item($params);
?>
//test_views_day is a num field
//test_views_dates is a date field
Error: Parse error: syntax error, unexpected '[' in /home/kunal17/public_html/devbuzzr/wp-content/plugins/pods/classes/PodAPI.php(501) : eval()'d code on line 2
3 Answers
Looks like there's some trouble with one of your Pre-save / Post-save Helpers. Check there or post the code for review.
thanks, it was a pre-save helper had a $ missing
$columns['slug']['value'] = sanitize_title(columns['post_name']['value']);
should have been
$columns['slug']['value'] = sanitize_title($columns['post_name']['value']);
but what i fail to understand is that this code was working when a entry was added by the UI of pods, but when i used the API it showed this error, & how is it that without the $ sign the value even showed up?
I'm not sure why it would work when adding via the normal UI of Pods, other than the normal form uses AJAX for submission and could be masking the real problem. If the slug is empty, it will automatically use the 'name' field of the Pod item.


