WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. sp880111
    Member
    Posted 4 months 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

    https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/

  2. sevenspark
    Member
    Plugin Author

    Posted 4 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic