PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. 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.

Thumbnails From Two Forms

  1. Chris Higgins
    Member

    Hi everyone,

    I'm using Gravity Forms on a website I'm in the process of building, and I've used the solution detailed in this post to allow the client to create posts with thumbnails from a front-end form:

    http://www.gravityhelp.com/forums/topic/fatal-error-when-using-the_post_thumbnail-code-snippet#post-30918

    However, I'd like to create a second form for a different category that features different content, but I'm having some difficulty. It seems it's not as simple as just copying and editing the code already inserted into the functions.php file, as the browser then returns an error.

    Fatal error: Cannot redeclare gform_set_post_thumbnail() (previously declared in...

    I'm still in the very early stages of learning PHP, and I'm not quite sure how to resolve this issue. Can anyone offer any advice?

    Cheers,

    Chris

    Posted 13 years ago on Monday October 24, 2011 | Permalink
  2. Rename this function when you use it the second time:

    gform_set_post_thumbnail

    Call it ch_gform_set_post_thumbnail or something. It will be used on two lines: once for the function call, and once for the hook. In the code example you linked to, it's on lines 4 and 5. You can leave your original function alone, in two places, but in the new code you pasted in, you need to change the name to something different.

    Posted 13 years ago on Monday October 24, 2011 | Permalink
  3. Chris Higgins
    Member

    Legend! Cheers Chris. Much appreciated. :-)

    Posted 13 years ago on Tuesday October 25, 2011 | Permalink
  4. You're welcome. Glad that worked for you.

    Posted 13 years ago on Tuesday October 25, 2011 | Permalink

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