Contact Form 7 Dynamic Text Extension
[resolved] How to use shortcodes in hidden dynamic fields? (2 posts)

  1. sp880111
    Posted 2 years ago #

    Imagine I am able to retrieve an e-Mail address on the page the form is included via
    <?php echo do_shortcode('[CF7_get_email_from_post_id post_id="'.$id.'"]'); ?>

    Now, how can I use this email address as the recipient email address in the form?

    I tried to use a dynamic hidden field:

    [dynamichidden recipient-email "CF7_get_email_from_post_id post_id=$id"]
    [recipient-email] then goes into the To field of the Contact Form.

    My main problem here is the post_id parameter of the short code. I can't figure out how to set it up correctly.

    Thank you


  2. sevenspark
    Plugin Author

    Posted 2 years ago #

    You can't pass a PHP variable in a shortcode. The shortcode handler function would need to be responsible for determining the ID if it is dynamic (most likely $post->ID, just use global $post if referring to the current page), or you could pass a static value instead.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7 Dynamic Text Extension
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic