Is it possible to use php in an html field? Or is there some other workaround?
Is it possible to use php in an html field? Or is there some other workaround?
Hi, sascha,
No, you cannot put php in an html field. What are you trying to do?
I am trying to show a post image on the form. I have the attachment ID of the image, but I am not sure what the best way is to actually show it on the form.
Since this was answered in your other post, http://www.gravityhelp.com/forums/topic/displaying-post-images-in-form, I am closing this one.
PHP cannot be executed in the HTML field as Dana explained. This is for security reasons.
However, the HTML field does support WordPress shortcodes. If you place a shortcode in the HTML field it will be processed and parsed when the form is displayed.
So another solution is going to be for you to create your own custom WordPress shortcode using PHP. You can simply encapsulate the functionality you want into your own custom shortcode and then you can place that shortcode in your HTML field.
This will allow you to execute your custom PHP in a safe and secure way.
You would place the code for your shortcode either in your themes functions.php file OR create your own custom WordPress plugin and then activate it.
Here is the WordPress.org Codex page for the Shortcode API:
http://codex.wordpress.org/Shortcode_API
Here is a details tutorial on how to create WordPress Shortcodes:
http://wp.tutsplus.com/tutorials/theme-development/wordpress-shortcodes-the-right-way/