Advertisement
verygoodplugins

Untitled

Jun 11th, 2021
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. function wpf_create_sandbox( $update_data, $user_id, $contact_id, $form_id ) {
  2.  
  3.     if ( $form_id == 6 ) {
  4.  
  5.         $email = explode( '@', $update_data['email'] );
  6.  
  7.         // Stop spammers
  8.         if ( is_numeric( $email[0] ) ) {
  9.             return;
  10.         }
  11.  
  12.         $args = array(
  13.             'timeout' => 20,
  14.         );
  15.  
  16.         $response = wp_remote_post( 'https://wpfusiondemo.com/wp-json/llmstm/v1/sites?key=0mZoq6VBhce3&type=trial&template=cool-violet&email=' . urlencode( $update_data['email'] ), $args );
  17.  
  18.         if ( is_wp_error( $response ) ) {
  19.             error_log( 'ERROR' );
  20.             error_log( print_r( $response, true ) );
  21.         }
  22.  
  23.         $response = json_decode( wp_remote_retrieve_body( $response ) );
  24.  
  25.         $update_data = array(
  26.             'field[30,0]' => $response->login_url_priv,
  27.             'field[31,0]' => $response->password,
  28.         );
  29.  
  30.         wp_fusion()->crm->update_contact( $contact_id, $update_data, false );
  31.  
  32.     }
  33.  
  34. }
  35.  
  36. add_action( 'wpf_forms_post_submission', 'wpf_create_sandbox', 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement