/includes/Actions/Save.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2.  
  3. /** 
  4. * Class NF_Action_Save 
  5. */ 
  6. final class NF_Actions_Save extends NF_Abstracts_Action 
  7. /** 
  8. * @var string 
  9. */ 
  10. protected $_name = 'save'; 
  11.  
  12. /** 
  13. * @var array 
  14. */ 
  15. protected $_tags = array(); 
  16.  
  17. /** 
  18. * @var string 
  19. */ 
  20. protected $_timing = 'late'; 
  21.  
  22. /** 
  23. * @var int 
  24. */ 
  25. protected $_priority = '-1'; 
  26.  
  27. /** 
  28. * Constructor 
  29. */ 
  30. public function __construct() 
  31. parent::__construct(); 
  32.  
  33. $this->_nicename = __( 'Store Submission', 'ninja-forms' ); 
  34.  
  35. /** 
  36. * PUBLIC METHODS 
  37. */ 
  38.  
  39. public function save( $action_settings ) 
  40.  
  41.  
  42. public function process( $action_settings, $form_id, $data ) 
  43. if( isset( $data['settings']['is_preview'] ) && $data['settings']['is_preview'] ) { 
  44. return $data; 
  45.  
  46. if( ! apply_filters ( 'ninja_forms_save_submission', true, $form_id ) ) return $data; 
  47.  
  48. $sub = Ninja_Forms()->form( $form_id )->sub()->get(); 
  49.  
  50. $hidden_field_types = apply_filters( 'nf_sub_hidden_field_types', array() ); 
  51.  
  52. foreach( $data['fields'] as $field ) { 
  53.  
  54. if( in_array( $field[ 'type' ], array_values( $hidden_field_types ) ) ) { 
  55. $data['actions']['save']['hidden'][] = $field['type']; 
  56. continue; 
  57.  
  58. $field[ 'value' ] = apply_filters( 'nf_save_sub_user_value', $field[ 'value' ], $field[ 'id' ] ); 
  59.  
  60. $sub->update_field_value( $field[ 'id' ], $field[ 'value' ] ); 
  61.  
  62. if( isset( $data[ 'extra' ] ) ) { 
  63. $sub->update_extra_values( $data['extra'] ); 
  64.  
  65. do_action( 'nf_before_save_sub', $sub->get_id() ); 
  66.  
  67. $sub->save(); 
  68.  
  69. do_action( 'nf_save_sub', $sub->get_id() ); 
  70. do_action( 'nf_create_sub', $sub->get_id() ); 
  71. do_action( 'ninja_forms_save_sub', $sub->get_id() ); 
  72.  
  73. $data[ 'actions' ][ 'save' ][ 'sub_id' ] = $sub->get_id(); 
  74.  
  75. return $data; 
.