Guest User

Update status with Gravity Forms

a guest
Aug 16th, 2022
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1.     /**
  2.      * When processing Gravity Form #7 update Offer (which is a custom post type) post status to accepted (which is a custom post status)
  3.      *
  4.      * @since    1.0.0
  5.      */
  6.     function oxygen_child_accept_offer ( $entry, $form ) {
  7.        
  8.         $gf_offer_id = $entry[4];       // Offer ID (hidden field), must be dynamically populated with the post ID for this to work
  9.         global $wp_query, $post;
  10.        
  11.         if ( $gf_offer_id ) {
  12.             // Update the Offer with the status accepted ****************************
  13.             $offer_post = array(
  14.                 'ID' => $gf_offer_id,
  15.                 'post_status'   => 'accepted',
  16.                 // this is a custom status, it could have been 'publish','draft', etc.
  17.             );
  18.            
  19.             wp_update_post( $offer_post );
  20.                     // ****************************************************************************************************
  21.         }
  22.     }
  23.     // Gravity Form #7, change the ID to your form's ID
  24.     add_action( 'gform_after_submission_7', 'oxygen_child_accept_offer', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment