NF_Actions_Save

Class NF_Action_Save.

Defined (1)

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

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