WordPress.org

Ready to get started?Download WordPress

Forums

Grunion Contact Form
Grunion contact form via PHP? (9 posts)

  1. Clifford Paulick
    Member
    Posted 3 years ago #

    Is there any PHP code to include Grunion contact form, instead of shortcode?
    Did I miss it in the FAQs or previous support questions? I'm surprised this isn't readily available information.
    Thanks.

    http://wordpress.org/extend/plugins/grunion-contact-form/

  2. Milan Dinić
    Member
    Posted 3 years ago #

    do_shortcode( '[contact-form]' )

  3. Clifford Paulick
    Member
    Posted 3 years ago #

    Milan,

    Thanks for the reply.

    Other than do_shortcode with the most basic shortcode format that Grunion allows, are there PHP fields/parameters? Or can you also put the longer shortcodes (like [contact-form to="some-php-code-to-get-custom-field"] [contact-field label="Name" type="name" required="true" /] [contact-field label="Email" type="email" required="true" /] [contact-field label="Message" type="textarea" required="true" /] [/contact-form] within do_shortcode?

  4. Clifford Paulick
    Member
    Posted 3 years ago #

    Really, what I'm looking for are the PHP pieces, so that I can call a custom field value as the "to" email address. I sure wish it were simpler than PHP. I hope I'm missing something easy...

  5. Milan Dinić
    Member
    Posted 3 years ago #

    You can put whole Grunion's shortcode or even put several different shortcodes. What this function does is searching for any shortcode in text that is passed to it.

    It's actually used in core for post content. See documentation.

  6. Clifford Paulick
    Member
    Posted 3 years ago #

    The issue is that Grunion uses quotes for the to="___" field.

    So you can't do something like this:
    <?php echo do_shortcode( '[contact-form to="echo get_post_meta($post->ID, 'custom_field_email_address', true);"]' ) ?>

    And, even if you turned the custom field into its own shortcode to put within the to="" field...
    http://codex.wordpress.org/Shortcode_API#Square_Brackets

    If Grunion had a straight-forward PHP code to set the to="" field in PHP, I think that would work...
    hence, my original question.

    I'd love to find out one of my "known" limitations is wrong... Or if there's a workaround.

    Thanks!

  7. Milan Dinić
    Member
    Posted 3 years ago #

    How about this?

    <?php
    $custom_field_email_address = get_post_meta($post->ID, 'custom_field_email_address', true);
    
    echo do_shortcode( '[contact-form to="' . $custom_field_email_address . '"]' );
    ?>
  8. Clifford Paulick
    Member
    Posted 3 years ago #

    It worked! :)

    Thanks!

    1)
    Is there any potential problem with these 2 having the same name?
    $custom_field_email_address = get_post_meta($post->ID, 'custom_field_email_address', true);

    2)
    Could your code be customized to allow for multiple "to" addresses, from a single custom field (no change to code?) or by pulling in multiple custom fields (into an array?)

    Thanks A LOT!

  9. Clifford Paulick
    Member
    Posted 3 years ago #

    Another idea...
    Could you escape the quotes? I'm guessing that is dependent upon do_shortcode's setup.(?)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic