wpcf7_flamingo_submit

The Contact Form 7 wpcf7 flamingo submit function.

Description

wpcf7_flamingo_submit( $contactform, $result ); 

Parameters (2)

0. $contactform
The contactform.
1. $result
The result.

Usage

  1. if ( !function_exists( 'wpcf7_flamingo_submit' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/modules/flamingo.php'; 
  3.  
  4. // The contactform. 
  5. $contactform = null; 
  6.  
  7. // The result. 
  8. $result = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_flamingo_submit($contactform, $result); 
  12.  

Defined (1)

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

/modules/flamingo.php  
  1. function wpcf7_flamingo_submit( $contactform, $result ) { 
  2. if ( ! class_exists( 'Flamingo_Contact' ) 
  3. || ! class_exists( 'Flamingo_Inbound_Message' ) ) { 
  4. return; 
  5.  
  6. if ( $contactform->in_demo_mode() 
  7. || $contactform->is_true( 'do_not_store' ) ) { 
  8. return; 
  9.  
  10. $cases = (array) apply_filters( 'wpcf7_flamingo_submit_if',  
  11. array( 'spam', 'mail_sent', 'mail_failed' ) ); 
  12.  
  13. if ( empty( $result['status'] ) 
  14. || ! in_array( $result['status'], $cases ) ) { 
  15. return; 
  16.  
  17. $submission = WPCF7_Submission::get_instance(); 
  18.  
  19. if ( ! $submission || ! $posted_data = $submission->get_posted_data() ) { 
  20. return; 
  21.  
  22. $fields_senseless = $contactform->scan_form_tags( 
  23. array( 'type' => array( 'captchar', 'quiz', 'acceptance' ) ) ); 
  24.  
  25. $exclude_names = array(); 
  26.  
  27. foreach ( $fields_senseless as $tag ) { 
  28. $exclude_names[] = $tag['name']; 
  29.  
  30. $exclude_names[] = 'g-recaptcha-response'; 
  31.  
  32. foreach ( $posted_data as $key => $value ) { 
  33. if ( '_' == substr( $key, 0, 1 ) || in_array( $key, $exclude_names ) ) { 
  34. unset( $posted_data[$key] ); 
  35.  
  36. $email = wpcf7_flamingo_get_value( 'email', $contactform ); 
  37. $name = wpcf7_flamingo_get_value( 'name', $contactform ); 
  38. $subject = wpcf7_flamingo_get_value( 'subject', $contactform ); 
  39.  
  40. $meta = array(); 
  41.  
  42. $special_mail_tags = array( 'remote_ip', 'user_agent', 'url',  
  43. 'date', 'time', 'post_id', 'post_name', 'post_title', 'post_url',  
  44. 'post_author', 'post_author_email' ); 
  45.  
  46. foreach ( $special_mail_tags as $smt ) { 
  47. $meta[$smt] = apply_filters( 'wpcf7_special_mail_tags',  
  48. '', '_' . $smt, false ); 
  49.  
  50. $akismet = isset( $submission->akismet ) ? (array) $submission->akismet : null; 
  51.  
  52. if ( 'mail_sent' == $result['status'] ) { 
  53. $flamingo_contact = Flamingo_Contact::add( array( 
  54. 'email' => $email,  
  55. 'name' => $name ) ); 
  56.  
  57. $channel_id = wpcf7_flamingo_add_channel
  58. $contactform->name(), $contactform->title() ); 
  59.  
  60. if ( $channel_id ) { 
  61. $channel = get_term( $channel_id,  
  62. Flamingo_Inbound_Message::channel_taxonomy ); 
  63.  
  64. if ( ! $channel || is_wp_error( $channel ) ) { 
  65. $channel = 'contact-form-7'; 
  66. } else { 
  67. $channel = $channel->slug; 
  68. } else { 
  69. $channel = 'contact-form-7'; 
  70.  
  71. $args = array( 
  72. 'channel' => $channel,  
  73. 'subject' => $subject,  
  74. 'from' => trim( sprintf( '%s <%s>', $name, $email ) ),  
  75. 'from_name' => $name,  
  76. 'from_email' => $email,  
  77. 'fields' => $posted_data,  
  78. 'meta' => $meta,  
  79. 'akismet' => $akismet,  
  80. 'spam' => ( 'spam' == $result['status'] ) ); 
  81.  
  82. $flamingo_inbound = Flamingo_Inbound_Message::add( $args ); 
  83.  
  84. $result += array( 
  85. 'flamingo_contact_id' => 
  86. empty( $flamingo_contact ) ? 0 : absint( $flamingo_contact->id ),  
  87. 'flamingo_inbound_id' => 
  88. empty( $flamingo_inbound ) ? 0 : absint( $flamingo_inbound->id ) ); 
  89.  
  90. do_action( 'wpcf7_after_flamingo', $result );