nf_optin_send_admin_email

The Ninja Forms nf optin send admin email function.

Description

nf_optin_send_admin_email(); 

Usage

  1. if ( !function_exists( 'nf_optin_send_admin_email' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/ninja-forms.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = nf_optin_send_admin_email(); 
  7.  

Defined (1)

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

/ninja-forms.php  
  1. function nf_optin_send_admin_email( ) { 
  2. /** 
  3. * If we aren't opted in, or we've specifically opted out, then return false. 
  4. */ 
  5. if ( ! Ninja_Forms()->tracking->is_opted_in() || Ninja_Forms()->tracking->is_opted_out() ) { 
  6. return false; 
  7.  
  8. /** 
  9. * If we haven't already submitted our email to api.ninjaforms.com, submit it and set an option saying we have. 
  10. */ 
  11.  
  12. if ( get_option ( 'ninja_forms_optin_admin_email', false ) ) { 
  13. return false; 
  14.  
  15. /** 
  16. * Ping api.ninjaforms.com 
  17. */ 
  18.  
  19. $admin_email = get_option('admin_email'); 
  20. $url = home_url(); 
  21. $response = wp_remote_post( 
  22. 'http://api.ninjaforms.com',  
  23. array( 
  24. 'body' => array( 'admin_email' => $admin_email, 'url' => $url ),  
  25. ); 
  26.  
  27. if( is_array($response) ) { 
  28. $header = $response['headers']; // array of http header lines 
  29. $body = $response['body']; // use the content 
  30.  
  31. update_option( 'ninja_forms_optin_admin_email', true );