pods_api_post_save_pod_item_{podname}

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


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

Usage

add_action('pods_api_post_save_pod_item_my_pod_name', '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 item being updated

Examples

Update Taxonomy With Value Of Field Related To Taxonomy

Takes the value of a single-select field ‘genre’ related to the taxonomy ‘genres’ and updates the taxonomy with the term set in the ‘genre’ field from the custom post type ‘films’.

<?php  
add_action( 'pods_api_post_save_pod_item_films', 'my_tax_update', 10, 3 ); 

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

     //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 ); 
}
?>

 

Update Post Author To Current User

<?php 
    add_action('pods_api_post_save_pod_item_inventory_request', 'slug_author_save_function', 10, 3); 
      
    function slug_author_save_function($pieces, $is_new_item, $id ) { 
            
            if ( ! wp_is_post_revision( $id ) ){ 
                    
                    remove_action('pods_api_post_save_pod_item_inventory_request', 'slug_author_save_function');
                    
                    $user_ID = get_current_user_id(); 
                    
                    $my_args = array( 
                            'ID' => $id, 
                            'post_author' => $user_ID 
                    ); 
                    
                    wp_update_post( $my_args ); 
                    
                    add_action('pods_api_post_save_pod_item_inventory_request', 'slug_author_save_function'); 
            } 
    }
?>

 

Additional Information

  • This is the 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_item

Called after any Pod item is saved for any Pod

pods_api_save_pod_default_pod

Set Default Pod fields on creation