How do I enable the PHP filter only for webforms? How do I enable the PHP filter only for webforms, and not other content types?
I suggest is in your custom module add more description to your field that user enter php code with Not surround it with&lt;?php ?&gt; then in your submit handler that runs before other submit handler ( add it with array_unshift) use php eval then put your returned data in your field.


  Eval :mixed eval ( string $code ) eval — Evaluate a string as PHP code
  
  code

Valid PHP code to be evaluated.

The code mustn't be wrapped in opening and closing PHP tags, i.e. 'echo "Hi!";' must be passed instead of '&lt;? echo "Hi!"; &gt;'. It is

  
  still possible to leave and reenter PHP mode though using the
  appropriate PHP tags, e.g. 'echo "In PHP mode!"; ?>In HTML mode!

Apart from that the passed code must be valid PHP. This includes that all statements must be properly terminated using a semicolon.

  
  'echo "Hi!"' for example will cause a parse error, whereas 'echo
  "Hi!";' will work.

A return statement will immediately terminate the evaluation of the code.

The code will be executed in the scope of the code calling eval(). Thus any variables defined or changed in the eval() call will remain

  
  visible after it terminates.
  
  Return Values ¶
  
  eval() returns NULL unless return is called in the evaluated code, in
  which case the value passed to return is returned. If there is a parse
  error in the evaluated code, eval() returns FALSE and execution of the
  following code continues normally. It is not possible to catch a parse
  error in eval() using set_error_handler().