pods_api_post_save_pod_item or save_post not working on frontend
-
Hi everyone,
I am pulling my hair out on this one. Almost at the point of changing from PODS, so please help if you can…I have been trying to get any action hook to fire when I insert and/or update a pod on the frontend form. I have tried pods_api_post_save_pod_item and pods_api_post_save_pod_item_my_pod_name but these do not seem to fire. I even tried save_post but that is not either. I am trying to do some tasks when the submit is clicked on the pods created form.
I have deactivated all other plugins, tried a different theme. I have run these in snippets and also in a custom plugin. I know the save_post works when I update a page or post.
Here is an example that is not triggered:
add_action('pods_api_post_save_pod_item', 'my_test_function', 10, 3); function my_test_function($pieces, $is_new_item, $id) { $myfile = fopen("podsubmitlog.txt", "a") or die("Unable to open file!"); $date = new DateTime(); $date = $date->format("y:m:d h:i:s"); $txt = "Test function ---- ".$date."\n"; fwrite($myfile, $txt); fclose($myfile); }
I also set the pods settings so that the api is enabled for the pod, as well as individual fields. I also tried changing the hook priority, etc.
The weird thing is that I stumbled upon this action hook, that does not appear in the PODS documentation. But it actually does fire. Can I use this???
function action_pods_form_after_submit( $pod, $fields, $params ) { // $thetitle = $pod->field('post_title'); $thetype = $pod->field('post_type'); $myfile = fopen("podsubmitlog.txt", "a") or die("Unable to open file!"); // ../wp-content/plugins/jamie/ $date = new DateTime(); $date = $date->format("y:m:d h:i:s"); $txt = $date."--".$thetitle."--".$thetype."\n"; fwrite($myfile, $txt); fclose($myfile); }; // add the action add_action( 'pods_form_after_submit', 'action_pods_form_after_submit', 10, 3 );
My form:
Just to be complete, my form is on a page, using this short code:add_shortcode( 'edit_sitter', function () { $out = ''; // init $theurlparamname = 'sittertitle'; $theparam = get_request_parameter($theurlparamname); $mypod = pods( 'sitter', $theparam ); $fields = array( 'post_title' => array( 'type' => 'text', 'label' => 'Name of Sitter)', 'required' => true ), 'email', 'cell', 'notes' => array( 'label' => 'My Notes', 'type' => 'paragraph' ), 'availability', 'sitteruserid' => array( 'hidden' => true, 'readonly' => true ), 'memberuserid' => array( 'hidden' => true, 'readonly' => true ) ); // note can't use defaults on edit $thebuttontxt = 'Save Changes'; $sURL = site_url(); // WordPress function to get site url //$thereturnlink = $sURL . '/my-sitters'; $thereturnlink = $sURL . '/view-sitter/?sittertitle='.$theparam; $out .= $mypod->form( $fields, $thebuttontxt, $thereturnlink ); return $out; } );
Again, the form functions correctly…
I am at a lose on what is happening. All pods features and all my 5 pod ityems save and work correctly. Any help is appreciated,
Jamie
- The topic ‘pods_api_post_save_pod_item or save_post not working on frontend’ is closed to new replies.