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');Â
            }Â
    }
?>
Action/Filter Related To
Related Actions/Filters
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.