ninja_forms_get_subs

Ninja_forms_get_subs() has been deprecated in favour of Ninja_Forms()->subs()->get( $args ) or Ninja_Forms()->form( 23 )->get_subs( $args ) You can also use WordPress queries ,since this is a custom post type.

Description

ninja_forms_get_subs( (array) $args = array() ); 

Parameters (1)

0. $args — Optional. (array) => array()
The args.

Usage

  1. if ( !function_exists( 'ninja_forms_get_subs' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/deprecated.php'; 
  3.  
  4. // The args. 
  5. $args = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_get_subs($args); 
  9.  

Defined (1)

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

/deprecated/includes/deprecated.php  
  1. function ninja_forms_get_subs( $args = array() ) { 
  2.  
  3. $plugin_settings = nf_get_settings(); 
  4.  
  5. if ( isset ( $plugin_settings['date_format'] ) ) { 
  6. $date_format = $plugin_settings['date_format']; 
  7. } else { 
  8. $date_format = 'm/d/Y'; 
  9.  
  10. if( is_array( $args ) AND ! empty( $args ) ) { 
  11.  
  12. $subs_results = array(); 
  13. $meta_query = array(); 
  14. $date_query = array(); 
  15.  
  16. if( isset( $args['form_id'] ) ) { 
  17. $meta_query[] = array( 
  18. 'key' => '_form_id',  
  19. 'value' => $args['form_id'],  
  20. ); 
  21.  
  22. if( isset( $args['action'])) { 
  23. $meta_query[] = array( 
  24. 'key' => '_action',  
  25. 'value' => $args['action'],  
  26. ); 
  27.  
  28. $query_args = array( 
  29. 'post_type' => nf_sub,  
  30. 'date_query' => $date_query,  
  31. 'meta_query' => $meta_query,  
  32. 'posts_per_page' => -1,  
  33. ); 
  34.  
  35. if( isset( $args['user_id'] ) ) { 
  36. $query_args['author'] = $args['user_id']; 
  37.  
  38.  
  39.  
  40. if( isset( $args['begin_date'] ) AND $args['begin_date'] != '') { 
  41. $query_args['date_query']['after'] = nf_get_begin_date( $args['begin_date'] )->format("Y-m-d G:i:s"); 
  42.  
  43. if( isset( $args['end_date'] ) AND $args['end_date'] != '' ) { 
  44. $query_args['date_query']['before'] = nf_get_end_date( $args['end_date'] )->format("Y-m-d G:i:s"); 
  45.  
  46. $subs = get_posts( $query_args ); 
  47.  
  48. if ( is_array( $subs ) && ! empty( $subs ) ) { 
  49. $x = 0; 
  50. foreach ( $subs as $sub ) { 
  51. $data = array(); 
  52. $subs_results[$x]['id'] = $sub->ID; 
  53. $subs_results[$x]['user_id'] = $sub->post_author; 
  54. $subs_results[$x]['form_id'] = get_post_meta( $sub->ID, '_form_id' ); 
  55. $subs_results[$x]['action'] = get_post_meta( $sub->ID, '_action' ); 
  56.  
  57. $meta = get_post_custom( $sub->ID ); 
  58.  
  59. foreach ( $meta as $key => $array ) { 
  60. if ( strpos( $key, '_field_' ) !== false ) { 
  61. $field_id = str_replace( '_field_', '', $key ); 
  62. $user_value = $array[0]; 
  63. $data[] = array( 'field_id' => $field_id, 'user_value' => $user_value ); 
  64.  
  65. $subs_results[$x]['data'] = $data; 
  66. $subs_results[$x]['date_updated'] = $sub->post_modified; 
  67.  
  68. $x++; 
  69.  
  70. return $subs_results;