pods_api_post_save_item

Called after any Pod item is saved for any Pod

Called after any Pod item is saved for any Pod

Usage

add_action('pods_api_post_save_pod_item', 'my_post_save_function', 10, 3);

function my_post_save_function($pieces, $is_new_item, $id) {

Parameters

PARAMETER TYPE DETAILS
$pieces (array)
$is_new_item (boolean)
$id (integer) ID of the item being updated

Examples

Basic Example

The usage here to target a specific Pod is for the purpose of illustration; if you are targeting a specific Pod it is probably better to use the pods_api_post_save_pod_item_{podname} filter.

<?php 
add_action('pods_api_post_save_pod_item', 'my_post_save_function', 10, 3); 

function my_post_save_function($pieces, $is_new_item, $id ) { 

        if ( $pieces['params']->pod == 'films' ) { 

           //get the value of the 'genre' field 
           $term = (int) $pieces[ 'fields' ][ 'genre' ][ 'value' ] 

           //if there is nothing there set $term to null to avoid errors 
           if ( empty( $term ) ) { 
                   $term = null;  
           } 

           //Set the term for taxonomy 'genres' with $term 
           wp_set_object_terms( $id, $term, 'genres', false ); 
      } 
}
?>

 

Action/Filter Related To

Additional Information

  • This is the second to last filter called in save_pod_item()
  • save_pod_item() (and thus, this filter) will only be called for WordPress objects if you have added one or more fields to the Pod.

Other Helpful Documentation on Action Hook Reference

pods_api_post_save_pod_item_{podname}

Called after any Pod item is saved for a specific Pod.

pods_api_save_pod_default_pod

Set Default Pod fields on creation