• Resolved lim2me

    (@lim2me)


    Pods version 2.5.1.1

    Following the instructions on the pods documentation, this is my code:

    $invoice = pods( 'invoice', $post_id );
    $invoice->save( 'invoice_sent_date', '2015-11-05' );

    The problem is that the updated value isn’t saved.

    For context, here is what I’m doing: I created a Custom Post Type called Invoice using the Pods admin interface. When I Publish a new Invoice, I’m using WordPress’s action hooks to call a custom function which contains the above code. The function will send an email then automatically update the field named invoice_sent_date with the current date (I’m using a value of 2015-11-05 for testing purposes)

    As mentioned, the save() function doesn’t seem to be working. Really stumped on this one.

    https://wordpress.org/plugins/pods/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Howdy,

    This forum post may be similar to your problem, check out the code provided and see if that may help. http://pods.io/forums/topic/saving-data-in-to-pod-fields-programatically/

    Thanks!

    Thread Starter lim2me

    (@lim2me)

    @nikv Thanks for the link but it’s not quite what I need. The problem is the pods_api_pre_save_pod_item_{podname} filter is called when the custom post type is either Published or Saved as Draft.

    There is a way to differentiate Publishing from Saving as a Draft by checking agains the $_POST data but I’m wondering if this is really the best solution. I may have to re-think how I’m going about this.

    My custom function must (1) Email the invoice, and (2) Update invoice_sent_date. I initially tied the function to the Publish button but didn’t think about Editing or Saving as Draft. At this point it may be better to have another button to explicitly send the invoice.

    I’m marking this thread as resolved for now. I need to re-think this. Thanks again for responding.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘save() function doesn't save field with updated value’ is closed to new replies.