To add some functionality with PHP code
Hi mate, I would like to view my gravity form entries with some functions. I have two number fields in my form. for example both fields contains number from user input. I want to calculate both field in frontend/view, but not storing in database. Just user will show the calculated value.
Another things is that- I have two date value field. I don't want to show up those value. I just want to show days between to dates of some calculation with two dates value.
Both of my requirements need some facilities to write PHP code for desired view.
Please add some functionality to write PHP code in view.
We do not recommend executing PHP inside the Custom Content field itself, because it poses large security risks. Instead, using the filters and shortcodes I describe below are better solutions.
There are two filters you can use to add your own custom PHP code:
These filters allow you to add your own custom PHP to the Custom Content field by using the add_filter() WordPress function in combination with either of the filters above.
You can also use shortcodes inside the Custom Content field.
You will be able to have your field say “Hello World” if you want by doing this:
- Add a Custom Content field
- Set the Custom Content field content to: [hello_world]
- Add this code to your functions.php file: https://gist.github.com/zackkatz/866157910ab5ecc102cc
This uses the add_shortcode() function to “hide” the PHP functions inside nice-looking text called a shortcode. You can generate your own code here: http://generatewp.com/shortcodes/
The best way to do this right now would be to create a shortcode and pass merge tags into the shortcode. That way, you can process the content using PHP, but you don't need the PHP to be inside the Custom Content field itself.
Here's more information about the Custom Content field: http://docs.gravityview.co/article/111-using-the-custom-content-field