PHP filter field behavior with Rules - can't use curl_exec I am on Drupal 7. I am trying to use Rules to execute custom PHP code. I am using PHP filter in order to achieve that. Inside that PHP filter I will use curl. The idea is to communicate with a remote API.

I already have one Drupal website running this code I want to use and it works like a charm. On this website I am using Rules, PHP filter and curl.

The issue is that I am porting the EXACT same code to a new website using the same set of tools (Rules, PHP filter, curl), but I can't save my code into PHP filter.

The field will allow me to save this

$data = array(
'User'          =&gt; 'someuser',
'Password'      =&gt; 'somepassword',
'Subject'       =&gt; 'Something',
'Message'       =&gt; 'Something',
'StampToSend'   =&gt; $account-&gt;created,
'MessageTypeID' =&gt; 1
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://someurl.com");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);


When I add the last line "$response = curl_exec($curl);", then Drupal won't save my Rule. No error messages, no messages in the Drupal logs, no anything. It will just fail to save the field. I can save all the code above, and Rules with PHP filter will accept it. When adding the curl_execute line, it simply won't save.

Any ideas on what I could do? Thank you!
I solved the issue by moving the code to a custom module, then everything worked. My best guess is that the PHP filter is somehow interpreting the code and filteirng out stuff it considers innapropriate.