Please Note: We are no longer using forums to facilitate standard support. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

php in html field

  1. sascha
    Member

    Is it possible to use php in an html field? Or is there some other workaround?

    Posted 3 years ago on Thursday February 9, 2012 | Permalink
  2. Hi, sascha,

    No, you cannot put php in an html field. What are you trying to do?

    Posted 3 years ago on Monday February 13, 2012 | Permalink
  3. sascha
    Member

    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.

    Posted 3 years ago on Monday February 13, 2012 | Permalink
  4. Since this was answered in your other post, http://www.gravityhelp.com/forums/topic/displaying-post-images-in-form, I am closing this one.

    Posted 3 years ago on Monday February 13, 2012 | Permalink
  5. 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/

    Posted 3 years ago on Monday February 13, 2012 | Permalink

This topic has been resolved and has been closed to new replies.

Support Tickets

Open A New Support Ticket
 Open A New Priority Support Ticket *

* Developer license holders only