ninja_forms_save_postdata

When the post is saved, saves our custom data.

Description

ninja_forms_save_postdata( $post_id ); 

Parameters (1)

0. $post_id
The post id.

Usage

  1. if ( !function_exists( 'ninja_forms_save_postdata' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/post-metabox.php'; 
  3.  
  4. // The post id. 
  5. $post_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_save_postdata($post_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/post-metabox.php  
  1. function ninja_forms_save_postdata( $post_id ) { 
  2. global $wpdb; 
  3. if(isset($_POST['nf_append_form'])) { 
  4. // verify if this is an auto save routine. 
  5. // If it is our form has not been submitted, so we dont want to do anything 
  6. if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 
  7. return $post_id; 
  8.  
  9. // verify this came from the our screen and with proper authorization,  
  10. // because save_post can be triggered at other times 
  11.  
  12. if ( !wp_verify_nonce( $_POST['nf_append_form'], 'ninja_forms_append_form' ) ) 
  13. return $post_id; 
  14.  
  15. // Check permissions 
  16. if ( 'page' == $_POST['post_type'] ) { 
  17. if ( !current_user_can( 'edit_page', $post_id ) ) 
  18. return $post_id; 
  19. } else { 
  20. if ( !current_user_can( 'edit_post', $post_id ) ) 
  21. return $post_id; 
  22.  
  23. // OK, we're authenticated: we need to find and save the data 
  24. $post_id = absint( $_POST['post_ID'] ); 
  25. $form_id = absint( $_POST['ninja_form_select'] ); 
  26. if ( empty ( $form_id ) ) { 
  27. delete_post_meta( $post_id, 'ninja_forms_form' ); 
  28. } else { 
  29. update_post_meta( $post_id, 'ninja_forms_form', $form_id );