Support » Plugins and Hacks » Grunion Contact Form » [Plugin: Grunion Contact Form] Grunion contact form via PHP?

[Plugin: Grunion Contact Form] Grunion contact form via PHP?

Viewing 8 replies - 1 through 8 (of 8 total)
  • do_shortcode( '[contact-form]' )


    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?

    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…

    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.

    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…

    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.


    How about this?

    $custom_field_email_address = get_post_meta($post->ID, 'custom_field_email_address', true);
    echo do_shortcode( '[contact-form to="' . $custom_field_email_address . '"]' );

    It worked! 🙂


    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);

    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!

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Grunion Contact Form] Grunion contact form via PHP?’ is closed to new replies.
Skip to toolbar