Populate Contact Form 7 with the author information

I get the author email of a post in WordPress this way:

$author_email = get_the_author_meta('email', $post->post_author);

I would like to use the variable to populate the “to:” form of Contact Form 7.
I’ve been trying to use “Contact Form 7 Dynamic Text Extension” and pass it as a shortcode ( following this : http://sevenspark.com/wordpress-plugins/how-to-dynamically-set-the-recipient-to-email-address-in-contact-form-7 )

add_shortcode('value_author_email', $author_email);

And then print it in the Form :

[dynamictext recipient-email "CF7_get_custom_field key='value_author_email'"]

The issue : I can’t seem to retrieve the email. In my form, the field stays empty. I’m not sure where the problem happens.


Source: shortcode

Leave a Reply