Contact Form 7 – Dynamic Text Extension Released

Sorry, comments are closed due to ridiculous amounts of sp*m. Please use the forums for support. Thanks!

I’ve just released my first WordPress Plugin: Contact Form 7 – Dynamic Text Extension.

I’ve used the Contact Form 7 Plugin several times on my own sites and on client sites. It’s an excellent, highly flexible plugin. But I recently needed to populate the form dynamically, and found this functionality was not build in to the plugin.

I found other people with similar issues. Several possible solutions are suggested in this thread, Contact Form 7 Input Fields Values as PHP Get-Viarables, but they are all hacks and involve changing the Contact Form 7 code, which is bad for a variety of reasons. The new plugin provides a better solution, hooking into Contact Form 7’s API and adding a new input type: Dynamic Text. This input type takes a shortcode-style input that is evaluated at run time, so it can be completely dynamic.

For example, say you have a GET parameter in the URL that you want to use to populate the contact form. You just set the Dynamic Text field up with the included shortcode and GET key, and the value will automatically be populated. Cool! Better yet, the plugin will work with any shortcode that returns a valid text string, so you can easily extend the plugin just by writing your own shortcodes. Awesome!

Anyway, the plugin is now available through Let me know if it helps you out!

Download the Plugin Donate

190 thoughts on “Contact Form 7 – Dynamic Text Extension Released

  1. I love this plugin! I’ve been trying to do something like this for a long time but everyone tells me it’s not possible. You rock. There’s just one thing I can’t figure out.

    I want to be able to have the page title, slug or url added to a field to be exported with the other fields with the Database Extension plugin.

    Are there bloginfo variables for those results (like the URL or sitename) or would this require a totally different short code, like something based on get_page?

    Or maybe pull data from the CF7 “special mail tags” like [_post_title] that can be added to an email?


    • Hi Andy,

      Thanks! Glad you’re enjoying the plugin!

      It sounds to me like you need access to the variables for the current post/page. This will require a new shortcode, but I like this idea very much – I think it’d be very useful.

      I have some updates to make to the plugin, and I’ll add this to the list. If you’re looking to get something working in the meantime, a good starting point would be to create a shortcode that grabs the global $post variable and returns the value you need (like $post->post_title for the title).

      I’ll post back here when I’ve made the update πŸ™‚


    • Hey Andy,

      I’ve released a new version of the plugin (1.0.3) that should give you what you’re looking for. Quick rundown of the highlights:

      Get the title
      CF7_get_post_var key='title'

      Get the slug
      CF7_get_post_var key='slug'

      Get the current URL

      Hope the new changes help you out!


  2. I also love this it is helping me get somewhere I really needed — which was the ability to have a form go to different email addresses based on the page it was submitted from (without having to make a bunch of different forms).

    On thing I think would be a great addition is another checkbox to “Hide”. So, if checked then instead of displaying the field as a text box (even if un-editable) it can put it in as a hidden form element.

    I also agree with the above poster — the ability to get special tags would be awesome. I think if you could make a tag can pull a CUSTOM FIELD that would make an amazing addition.


    CF7_get_custom_field key=’custom_field_name’

    • Actually, it might be nice just to also ADD a “hidden” element in the CF7 pulldown. All that would need to be set there was the name and the value.

    • Yup, a hidden form element has been on my to-do list, as I agree this would be very valuable in many cases, and would improve UX. Gotta find some time to get to this, soon hopefully πŸ™‚

      I like your custom field idea as well, that could add a lot of versatility for more advanced users.

      As for the Special Mail Tags, I think that most are covered by the CF7_get_post_var and CF7_URL shortcodes. The only ones that are missing (from this list: CF7 Special Mail Tags) seem to be the sender’s IP, author name, and author email – though as you can already include these normally in CF7, I’m not sure what adding this feature to CF7 Dynamic Text Extension would buy you. Unless perhaps it’s to store values in the DB

      Of course, the great thing is that users could always write their own shortcodes and use them with CF7 DTX to obtain any value they want πŸ™‚


  3. Hi Chris,

    Congratulations for your extension, is awesome!

    I’m not very acquainted with PHP and i’m trying to create a new shortcode to get “current_user_info” like: login, email, user_firstname, user_lastname, email, … but i don’t.

    I think that is like “get_bloginfo” but i can’t make well. Can you help me?

    Thanks in advance πŸ˜‰

    • Hi Perrazoo,

      Glad you like the plugin πŸ™‚ I think to get the current user info you’d write a shortcode like this:

      function my_get_current_user($atts){
      		'key' => 'user_login',
      	), $atts));
      	global $current_user;
      	$val = $current_user->$key;
      	return $val;
      add_shortcode('my_get_current_user', 'my_get_current_user');

      Then you could use the shortcode like this in your tag:

      my_get_current_user key='user_login'

      where the key is any variable from this page – for example, user_login, user_email, user_firstname, user_lastname, display_name, ID

      I haven’t tested this, but that’s the basic idea. Also, I’ll add this to my list of shortcodes to include in the next release.

      Hope that helps!


  4. Hey Chris!!

    Thanks a lot!!!!!! I have tried and it works fine!!

    My idea was very similar but i only use “login” instead “user_login”!!! A question, why do you user “user_login” in:

    ‘key’ => ‘user_login’,
    ), $atts));

    why not “user_email” or..

    Again i’m really grateful for your quick and efficient answer!!


    PS: You should include this on the next release. I think is very usefull this information

    • Glad to hear it worked for you πŸ™‚

      The code you mentioned simply sets up the default value for key. So if you were to leave out the key attribute when writing the shortcode, it would default to using the current user’s login. It just makes the shortcode more robust.

      If you wanted it to default to something else, you could change 'key' => 'user_login', to any of the valid values in the $current_user object, as listed previously. For example, 'key' => 'display_name', would default to the user’s display name.

      I’ll plan to include it in the next release πŸ™‚

  5. Hi Chris

    Thanks for your great plugin. Can i ask you a question.

    I have many product posts, for example post A, B, C ..etc, in the post content i have a button, (choose this) , it links to contact form page. How to retrieve the post title where user click the button.. in contact form?

    For example, if user clicks the button from post A, it takes to contact form page with the post A title retrieved in an uneditable input text field

    Hope you can help


    • Hi Henry,

      Basically, you will need to pass that variable (page title) to the contact form page. One way to do this would be to make the button submit a form containing that value. You could then retrieve the value using the CF7_GET or CF7_POST shortcodes, depending on your form method.

      An easier way would probably be to construct the link to the Contact Form page as a URL with GET parameters containing the page title encoded. Something along the lines of this (on the Product Page):

      ID)) .'">Contact Us</a>';

      On the contact form page, you'd retrieve the value using

      CF7_GET key='product_title'

      Hope that helps,


  6. Thanks for your reply

    I copied your code

    < ?php
    global $post;
    echo 'ID)) .'">Contact Us';

    to single.php for displaying the contact us button. but dreamweaver says there’s a syntax error

    hope you can help


    • Yeah, sorry, WordPress likes to mess with the syntax and spacing when you enter code snippets into comments. It was probably the space it added before the ‘?php’

      Glad it worked for you πŸ™‚

  7. I’m sorry for my bad english.

    I have an defined a custom_field for my different post and want to ad the costum_field to the mail. I can display the object_id by using

    $objectid_value = get_post_custom_values(“objektid”);
    $object_id = $objectid_value[‘0’];
    echo $object_id

    but how can I add the $object_id to my E-Mail ?

    I’m trying it now for hours.

    • Hi Dave,

      You’ll need to create a shortcode to get that info. Off the top of my head, something like:

      function cf7_get_custom_post_val($atts){
      		'key' => '',
      	), $atts));
      	$objectid_value = get_post_custom_values($key);
      	$val = $objectid_value[0];
      	return $val;
      add_shortcode('CF7_get_custom_post_val', 'cf7_get_custom_post_val');

      Then you can create a Contact Form 7 field like this:

      [dynamictext dynamicname "CF7_get_custom_post_val key='objectid'"]

      Hope that helps,


      • I copied the code after the line:
        /* Tag generator */

        and inserted it into the form. But now just an empty textfield is displayed.

        • Well, what was the code? It has to include a valid shortcode, and the shortcode has to return a non-empty value for anything to show up in the text field.

  8. Hi Chris,

    The extension is so clever just what I need ( I think)

    I’, using Contact Form 7 as a support ticket submission form.
    I’ve got it set up perfectly but I want to be able to generate random (or sequential) codes for each form submission.

    One suggestion was to use your extension have a hidden filed and link it somehow to a php random code generator and hide this field in the form.

    Does that sound possible? I know nothing about this

    • Hi Luke,

      Hidden fields are not currently supported (they will be in a future release), but you can make the field uneditable or just hide it via CSS.

      For the random/sequential number, you’d just create a shortcode that does what you want and returns the random number, then set it up like any other Dynamic Text Field.

      The function would be pretty simple, something like this:

      function cf7_get_rand($atts){
          return mt_rand();
      add_shortcode('CF7_get_rand', 'cf7_get_rand');

      And the CF7 tag would look like this

      [dynamictext ticketid "CF7_get_rand"]

      You could do something similar with sequential numbers.

      Or, you might pair it with the CF7 to Database Extension – I believe it produces an ID for every Contact Form and you might be able to harness that for your purposes, plus save all the support tickets in a DB. Might be another idea.

      Good luck!

  9. Hi there!
    I’d like to say that I love the work you have done on this plug-in!
    It’s very useful!

    I only have one problem:

    I’m using contact form 7 in my website template (by do_shortcode),
    and what I want is that the e-mail gets sent to an emailadress that is in a custom field… (I get the custom field to CF7 by setting the value as a $_POST variable)

    Which is something your plugin would do just fine, I could use the dynamic field and hide it with CSS.. BUT, when a visitor would look at the page source, they’d find the emailadress, which should remain hidden at all times… Is there any way to get the CF7_POST variable directly in to the mail section of CF7?

    • Hi Jeffrey,

      Thanks for your comment. I’ve been looking into your issue, but at this time I don’t think there is a good solution. You are probably aware of this page: , which accomplishes what you are looking for with the use of pipes – however, it only works with select boxes, radio buttons, or checkboxes (while the Dynamic Text Extension is for text boxes). I haven’t tested this method, but I assume it wouldn’t work here.

      I think it’s possible that I may be able to leverage a filter to accomplish the direct POST to TO in the future, but it’ll take some experimenting to figure out. I’ll add it to my to-do list, but I’m not sure when I’ll get to this, sorry.



  10. Hi Chris! I’m using CF7 to collect registration information for an event … but I need to have two different submit buttons: one for attendees, and one for speakers. I am so non-technical it’s not even funny. πŸ™ Is this something your extension can do? I’d appreciate any information you can give. Thank you!

    • Hi CT,

      You don’t need any special plugin to have two submit buttons. Here’s an explanation of how a two-submit-button form would work. – with Contact Form 7, you’d need to include two submit tags with the same name but different values.

      Another way to go would be to create a form with a dynamic field (which denotes attendee vs speaker) – this field could be set via this Dynamic Text Extension plugin. You would then use one submit button to submit the form, which would contain the registrant type as a value.

      How you go about it really depends on what your goal is when submitting the form, and how you intend to capture the information.

      Hope that helps,


  11. Desperately looking for a solution that allows a dynamic email address (custom field being stored as “email_address”) to be inserted into the TO: field in any contact form, let alone CF7. I don’t care if others can see the source code. I installed your plugin but I don’t think it’s built for this yet… any guidance would be fantastic and much appreciated. I’m also willing to contract you if you think it’s possible.


  12. It appears that your 1.0.4 plugin is causing some errors for me.

    You have two extra lines of white space at the end of the file that are causing headers already sent errors. I removed those and the errors disappear.

    • Drew, thanks very much for the heads up, and sorry for the trouble! I’ve just committed a new version to the repository, version – this removes the whitespace as well as the closing PHP tags, which should eliminate the problem. If you get a chance, would you let me know if the upgrade works smoothly for you? (Both versions work on my system).



  13. Hi Chris,
    first of all thank you for your Plugin!

    I’ve made a little modification, because the following effect appears:
    If the form doesn’t validate, the next iteration of calling your plugin displays the value of the shortcode in brackets like “[value_of_the_shortcut]”, the next iteration displays “[[value_of_the_shortcut]]” an so on…

    My solution is the following code-snippet:
    if (strpos($value, ‘CF7_’) !== false)
    $value = do_shortcode(‘[‘.$value.’]’);

    So the shortcode has to begin with “CF7_”

    • Christian, thanks so much for bringing this to my attention! I found that I could reproduce the issue when I disabled javascript and submitted non-validating forms. I’ve revisited the code and found a solution that will still allow for any shortcode to be used (rather than limiting it to the CF7_ prefix). It stops the code from adding superfluous square brackets:

      $scval = do_shortcode('['.$value.']');
      if($scval != '['.$value.']') $value = $scval;

      I’ve committed a new version,, that should be available for download shortly. If you want to check that out and see if it solves your issue as you’ve encountered it, I’d appreciate it!



  14. Hi Chris,

    I think you may be the one to help me.

    I am managing to pull a bunch of email adresses from a list of posts and I would like to send blind carbon copies (bcc) of a particular form to all these emails at once. So in short, I need to be able to insert a bunch of email adresses in the bcc recipient field.

    Is it something that your extension could do? Am hoping that a shortcode could be the solution.

    Am pretty bad at technical stuff so please bear with me on this issue.

    • Yes, this could be done I think. Basically, you’d either need those email addresses in a location that could be grabbed by CF7 DTX (POST variable, GET variable, or custom post field) or else write a shortcode that retrieves the email addresses in comma separated form. Then you could set up a hidden dynamic text field that uses that string as a value as usual (via the appropriate shortcode). Use that field’s tag to insert the BCC in the Additional Headers box as described here: and you’re good to go!

      Feel free to contact me directly (via the contact form on the About page) if you’re having trouble implementing the technical details you’d like me to take this on as a quick freelance project.

      Hope that helps,


      • Here is the function I created and put in the wpcf7_dynamic_text.php/ folder

        function cf7_hello()
        echo 'Hello World!';

        add_shortcode('CF7_HELLO', 'cf7_hello');

        Then in the CF7 form I added a text field with this shortcode:

        [dynamictext hello-text "'CF7_HELLO'"]

        Unfortunately on the website, the form displays ‘CF7_HELLO’ instead of Hello World!

        Can you point me toward the solution? What is the issue?


        • First, make your shortcode return a value rather than echo it.

          Second, your CF7_HELLO should only have the double quotes around it. Single quotes are only for attribute values (not shortcode names). i.e. [dynamictext hello-text "CF7_HELLO"]

          Third, you said you put the function in a folder but mentioned the file (.php). If you put it in the PHP file, that’s fine, you’ll just need to recreate it if you ever upgrade the plugin. If you created a new PHP file just for your shortcode, you’ll need to include it somehow (it won’t get picked up automatically).



  15. By the way, should I put my function inside functions.php ? I want to make sure it isn’t erased on your next update.


  16. Hi Chris,

    I just installed your plugin but am a complete novice with PHP short code etc. I’m setting up a closed community using wordpress so all user will be logged in to view the site. therefore all iwant in regards for a contact form is just text area and submit button. and have the users username and email dynamically populate the contact form 7 in the background. however i don’t have a cule about how to do this. is this something that you could please give me some advice on.

    Many thanks


    • Hi Ben,

      That functionality is built into CF7 DTX, so setting that up will be very easy. In addition to your normal CF7 tags for textarea and submit button, you’ll add hidden fields as well, one for each piece of info you want to collect. The shortcode you’ll use is this:

      CF7_get_current_user key='value'

      Where value is one of the attributes listed here. For example, to get a user’s email, the CF7 form tag would look like this:

      [dynamichidden user-email "CF7_get_current_user key='user_email'"]

      Then just insert the [user-email] into the message body or as a reply-to header and you’re good to go.

      Hope that helps,


      • Chris you are an absolute star.
        Thank you very much for that info very helpful. and your time is very much appreciated.
        Many Thanks


    • Hi, Great extension to a great plugin!

      I was wondering if it’s possible to validate a dynamictext field that might contain the email of the logged in user.

      I mean the email field is populated with the valid email of the user, but if the user changes his email, it might not be valid anymore.

      So his there a way to validate a dynamictext as a email?

  17. Firstly, I need to say Top marks for a great plugin! CF7 is a great plugin as it stands, but your plugin (addition) seems like a must have!

    I am currently trying to populate a form using the hidden fields..

    The page in question:

    I am using a WP plugin called WP Table Reloaded, and what I’m trying to do is pull in the info from the table cells, into CF7 (ie; LTV – 75% APR 3.2%) Is this possible?

    thanks in advance.

    • Hi Marc,

      The simplest way would basically be to submit those values to your contact page as POST variables, then retrieve them using the CF7_POST shortcode.

      On your tables page, you’d want to dynamically generate a form for each row, with each of the hidden fields that you want to pass to the contact form, and ‘Enquire’ as the submit button.

      Alternatively, you can write your own shortcode that populates your hidden fields in the contact form based on an ID of the lender (again passed via POST vars, or by the ID of a specific page), then query the database for these values on the form page.

      There are a variety of ways to accomplish what you want to do, you’ll have to pick the best one based on your site’s architecture; but it can certainly be done.

      Hope that helps,


  18. Hi Chris,

    Thanks for the rapid response! Much appreciated.

    What kind of shortcode would I need to produce? I’m not a hardcode programmer, and this kind of stuff has really thrown me.

    I have a deadline to meet and really starting to panic now!! πŸ™

    • It would really depend on the structure of your site.

      If you’re not comfortable writing the shortcode, I’d suggest going the first route. In the Enquire cell, just generate a form for each entry that includes the data you want to pass as hidden fields (I assume the table is dynamically generated?). Name your fields accordingly. Set the form to POST on submit (the submit button being the Enquire button). Submit the form to the contact page, retrieve the variables by their names, one dynamic hidden field for each using the CF7_POST shortcode.

      So your form looks something like this:

      And on the contact form your tags look like this:

      [dynamichidden ltv "CF7_POST key='LTV'"]
      [dynamichidden apr "CF7_POST key='APR'"]

      And you can access the values like this:

      [ltv] or [apr]

      Good luck πŸ™‚

  19. Thanks for the advice Chris.

    The table data is not dynamically generated, the fields in the data (ie; 7.5% etc..) are inputted by the client in the WP backend.

    • Well, you either need to harness those inputs to generate the hidden form fields (for example, through a shortcode or through custom post types), or you could use jQuery to gather the values from the table row and POST the variables to the contact form when the enquire button is clicked.

  20. …and the call I have in my footer.php is this (obviously still referencing gravity forms)

    $(function() {
    $(‘table.wp-table-reloaded’).tableGrabber({target:’.gform_body input.gform_hidden’,test:’#test’});

    • Yeah, you could probably adapt that. Though it’d likely be easier to just start from scratch (it wouldn’t be very complicated). Just keep in mind that if you’re doing a popup, you wouldn’t be using POST variables, so you’d just modify the hidden inputs in the contact form directly through jQuery. And in that case, the original values of the CF7 DTX hidden fields don’t really matter. The only functionality you’d gain from DTX is the ability to use hidden fields.

  21. Again thanks Chris, for all your help, and for a valuable Plugin.

    I slightly re-jigged the js file, and all seems to be working ok with this shortcode in the admin area – [dynamichidden other-info id:otherinfo]

    Just a quick one, Is it possible to populate the actual contact form popup with the details I mentioned (ie; APR, 2.5% etc..)?

    If you look at this page –

    When you click enquire you get CF7 popping up in a Modal. Is there anyway to have it look like …

    Mortgage Rates Enquiry

    Lender: Northern Rock
    LTV: 75%
    APR 3.2%

    Name field

    Email field

    thanks massively again

    • Hi Mark,

      It really depends on how the contact form is generated. If it is generated as a hidden element when that page is loaded, you could set those values via jQuery. If it is generated via an AJAX request, you can send the variables via POST and collect them using the CF7_POST shortcode in the contact form.

      Like I was saying before, in scenario 1, you’re not really using the dynamic capabilities of the DTX plugin, you’re just using hidden fields. Both the hidden fields and/or the visible fields that you are mentioning could only be changed via jQuery, because in this scenario there is no communication with the server between the Enquire button and the contact form. i.e. client-side code (javascript) has to do the work, not server-side code (PHP i.e. the shortcodes).

      Hope that clears things up for you.


  22. Hi Chris,

    great work ! a very usefull plugin !!

    i tried this :

    function cf7_user_meta($atts){
    		'key' => '',
    	), $atts));
    	$val = get_user_meta( $current_user->ID, $key, true ) ;
    	return $val;
     add_shortcode('CF7_user_meta', 'cf7_user_meta');

    to pick up some extra user_meta that i created but it still display :
    cf7_get_usermeta key=’$meta_key’…
    Don’t understand why it doesn’t work….

    Any Idea ?

    (sorry if i made more than ten mistakes by line…. french guy…)
    Best regards from France.


    • Glad you like the plugin πŸ™‚

      Two things:

      1. Your shortcode is CF7_user_meta, so if your tag is using “cf7_get_usermeta” instead then that’s your problem. Your tag should look like this:

      [dynamictext user-name "CF7_user_meta key='mykey']

      2. I don’t think $current_user is in the scope of your function. I think you need to include this in your function, prior to getting the user meta:

      global $current_user;

      Hope that helps,


      • Thanks reply so quickly.

        the error in the shortcode makes me think that 12 hours per day becomes a little bit too much…

        function is now :
        function cf7_user_meta($atts){

        ‘key’ => ”,
        ), $atts));

        global $current_user;

        // $val = get_user_meta( $current_user->ID, $key, true ) ;

        return $val;
        add_shortcode(‘CF7_user_meta’, ‘cf7_user_meta’);

        There’s still an issue : if i write directly the ‘value’ instead of $key in the function it works perfectly but if i live $key it returns me an empty string, as if $key was empty…

        if i return $atts[0] it returns ‘=value’ (same as in form) so it works to there…

        i made this :

        $forbid = array(“‘”, “=”);
        $clef = str_replace($forbid, “”, $atts[0]);

        ugly… but working ^^

        Thanks for your plugin again, makes me save my time !

  23. Hi Chris,

    Great Plugin. Wish I had found it sooner.

    Wondering if it were possible to include a variable list of items in a for each statement and have them output in their own ‘s.

    Had a crack at this but no avail. My Shortcode function returns a PHP template which returns up to 10 values I would like included in the form.

    `if ($favorite_post_ids):
    foreach ($favorite_post_ids as $post_id) {
    $p = get_post($post_id);
    echo ” . $p->post_title . “;

    Any ideas would be much appreciated!


    • Sorry, forgot to escape the code. Meant:

      > Wondering if it were possible to include a variable list of items in a for each statement and have them output in their own 's

      Also, just thought, not sure how i would get this info into the resulting email …


    • Hey Ben,

      I think the comments are stripping out your tags. Try wrapping your code in pre tags, and use square brackets instead of angle brackets for tags just so it’ll post properly.

      Not sure exactly what you’re trying to do, but for one thing your shortcode should return (not echo) the string that you want in the dynamictext field.

      To put the info into the email, you just use the name of the input field just like any other CF7 tag. i.e.:

      //Input tag looks like this:
      [dynamictext my-text-box "myshortcode"]
      //Insert this tag into the email body to send value:

      Hope that helps!


  24. Hi Christ, I am in love with contact form 7. Anyway, is it possible to add a counter to the cf7 database ? if not, can we use the quiz to generate the counter ?
    I dont know much about php code, but it should be like this

    Get last data from table A or Get data from A(hidden)
    write B = A + 1
    write A = B
    submit A back to the data.

    Sorry If I make you confused.
    Basically, I just need a counter for my database.
    thank you.

    • Hey Jeremy,

      Not 100% sure I understand, but you could write a shortcode that would put a counter into a field for you. The shortcode could look like this:

      function cf7_counter(){
          $val = get_option( 'cf7-counter', 0);
          update_option('cf7-counter', $val);
          return $val;
      add_shortcode('CF7_counter', 'cf7_counter');

      Just be aware that this counter would increment every time the contact form is viewed, not just when it is sent.

      Hope that helps,


      • Hello Chris,

        It is possible, that this counter would increment only when it is sent?

        Thanks, Norbi

        • The problem is that CF7 DTX only affects the CF7 form when it is generated, not when it’s sent.

          I suppose you could try hooking into CF7’s wpcf7_mail_sent action hook and increment the counter then, and just retrieve it in the cf7_counter function instead. That’d probably work.

          • And there are other solution this problem?

            I would like that the mail should have an ID and this number should be the mail subject.

            I use CF7 DTX and CF7 DBX.

  25. Hey Chris! Great Plugin. Is it possible to have a select box where the selected item is dynamically chosen? I.e. I can create links to my contact form like “contact?subject=Option1” or “contact?subject=Option2” and it will pre-select Option1 or Option2 for the user? I guess I should say, I know it’s possible, but is this something your plugin can do for me as it is?

    Thanks for your help.

    • Hi Duncan,

      Right now that’s not possible with CF7 DTX – it is specifically text inputs, not select boxes. I am considering adding this functionality in the future, but that’s some way down the road at this point. Sorry not to be more helpful!


  26. Hi Chris and thank’s for the good job you’ve done.

    Sorry for may bad english…a frenchie !

    In my wordpress site, i use custom post types and custom taxonomies.
    I also add some personalized meta from the standard wordpress “add a personal meta” option below the content editor. I searcha nd found my new personalized meta on the Mysql DB in the table “postmeta”.
    I’m trying to get this value without any success, do you have an idea?


  27. Hi,

    I have a strange question πŸ™‚
    I need to put about 10 contact form that are the same but for each of them i need to pass a number to the email.

    It like a gallery that in each photo there is a contact form. i need to put the image id in the contact form manually and to send it via email. how can i do that? i know that i am missing something.

    Any ideas would be much appreciated!


    • Depending on your setup, you could either:

      1. Have one contact form on a separate page that receives a POST OR GET variable in the URL – each image links to this page and passes the variable to the form.

      2. If each image is on a separate page, you could use the CF7_get_post_var shortcode to retrieve the ID

      Note if all images are on the same page and you have the contact form on the same page, you would need to change the value on the fly using javascript – or use an AJAX form submission that returns the contact form using method 1.

      Hope that helps,


  28. Cool – exactly the right plugin at just the right time!
    I am using Custom Post Types to allow a client create special offers and CF7 so customers can take up an offer. I needed a way to indicate which special offer the customer was taking up.

    I was searching through the CF7 code and docs and found your plugin at the bottom of the Docs page. Eureka! Thanks!

  29. I’m trying to use a shortcode that should return HTML like that:

    function generate_html(){

    $output.= ‘this is a test‘;
    $output.= ‘this is a test’;
    $output.= ‘this is a test‘;

    return $output;

    add_shortcode(‘show_html’, ‘generate_html’);

    it displays the output in the mail, but it doesn’t format the output in html. it displays this in the mail:
    this is a testthis is a testthis is a test

    when I check “use HTML-Content-Typ” in CF7 it just removes the HTML tags:

    this is a testthis is a testthis is a test

    Any Ideas how I can fix that?


    • damn my HTML got displayed like it shoul in my comment πŸ˜›
      function generate_html(){

      $output.= ‘this is a test‘;
      $output.= ‘this is a test’;
      $output.= ‘this is a test‘;

      return $output;

      add_shortcode(‘show_html’, ‘generate_html’);

  30. … sorry about that …”pre” doesn’t seem to work… well to make it short: all it returns is as a string of text and not formated HTML.

    I hope you can give me a hint to the solution.

    • Sorry, not sure why that would be happening. Try pasting the HTML into the email field in the admin area and submit the contact form. Perhaps CF7 always strips those tags, I’m not sure.

      • pasting the HTML code into the email field works fine … but that doesnt solve my problem πŸ™ …

        I can wrap the shortcode in HTML, but the HTML from the shortcode gets somehow rendered as plain text.

        • I know it won’t solve your problem, but it was a troubleshooting test.

          It just occurred to me why you can’t use HTML though. The value that is returned by the shortcode is entered into the value tag of the input element. That can’t contain any HTML, so it is automatically escaped on line 134 of the plugin:

          value="' . esc_attr( $value ) . '"'

          That’s why it spits out plain text – because the tags are encoded.

          So, you could use DTX fields to grab your dynamic values, then put them into HTML in your CF7 form. I see how that’s restrictive but unfortunately I don’t see a way around it for textboxes. I suppose a Dynamic Text Area (as opposed to text box) might fix the issue, as the value can contain HTML. You could create a new text area module from the text box code if you study it a bit.

          Good luck!


    • I found a workaround …

      If I check β€œuse HTML-Content-Typ” in CF7 it removes the HTML tags from my shordcode output, but when I uncheck it and add this line:

      Content-Type: text/html; charset=”UTF-8″

      to the additional headers field, it works just fine!
      So that way, outputing HTML code through your plugin works perfectly :D! THX man!

  31. Hi Chris,
    I’m found of your awesome plugin.
    I install it. I keep back the data of the user logged but when I clic on “submit” the email is not sent to the email address entered in the form.
    When I desactivate the plugin, the email is sent again with no problem.

    The only modifications I made are:
    1. Install the plugin (with no problem)
    2. Add the line in the Contact Form 7:
    [dynamictext user-email “CF7_get_current_user key=’user_email'”]

    Can you please help me.
    Thank in advance,

  32. Hi Chris,

    Sorry por the post.
    In fact, I don’t know why, OVH blacklisted hotmail addresses.
    I changed the hotmail address to a gmail one and every thing works fine.
    So, I confirm that your plugin is awesome and fantastic.
    Thank you again.


  33. hi chris…

    I have many posts in my website… and i want to write contact me under the posts.. And want to display the title of the post in contact form page.. I want to know in mails from which page they contacted with me…

    Can u help me pls?

    Henry asked this question before , i tried your method but it gave error…

    This method:

    < ?php
    global $post;
    echo 'ID)) .'”>Contact Us‘;

  34. thank you chris.. I tiried now, it doesnt give error but, i dont see post_title
    in my form dynamictext area, its blank.. i did as u said…

    • Did you set it up like this:

      In the form:

      [dynamictext posttitle "CF7_GET key='post_title' "]

      And then put [posttitle] in the message box


  35. Hi Chris

    Thanks for your great plugin. Works fine except one problem:

    I have put a post ( on my blog with the following code:
    global $post;
    echo 'ID)) .'”>Contact Us‘;
    in the contactform a have added two fields:
    [dynamictext dynamictext-628 uneditable “CF7_GET key=’context'”]
    [dynamictext dynamictext-984 70/ “CF7_URL”]
    The first one stays empty, the second one gives the actual URL of the contactform, but it has retrieved the ‘context’ variable, because it reads:

    So the problem is that the CF7_GET key doesn’t retrieve the variable.

    Any idea how to fix this?

    Thank you,


    • Hi Dirk,

      The issue seems to be that you are not using “pretty” permalinks – i.e. you are using ?page_id=953 instead of /contactform as your path. So the link you have created is invalid. That is,

      is not a valid URL. You can’t have two ?‘s in a URL. A proper URL/query string would be

      Then it would work. Or leave it the way you have it and change your permalink structure.



  36. Hi Chris, I have been looking for something like this for a long time but still in vain. I am building a website using wordpress. In one of its pages I have to include a list of of more than 60 employers with their phone numbers and a link that takes to a contact form through which we can send an email to that specific employer whose link has been clicked. Is there a way to get the form automatically populated with the recipient email? I do not know if your plugin would solve this issue for me. If you think that there is a solution to this problem, I would be so thankful to hear something from you. Thanks in advance.

    • Yup, that’s exactly what this plugin can do. See

      Except instead of using CF7_get_custom_field you’d use CF7_GET – then you’d build a link for each employer that passes the appropriate email address via URL query parameters. Better yet, if your employers are a custom post type, just pass the employer ID and retrieve the email address via a custom shortcode.

      • Thanks Chris for your prompt reply. In fact I can see that I am too close to resolve this issue by using your excellent pluggin, but I am afraid to pass the employees emails directly via URL to avoid spammers .
        The second option you stated was to create a post for each employer. This ultimate seems more efficient but in my case I was asked to put all of them in one single page as each employee only have three lines of text. Name, Phone number and Email link. Do you think that I can work this around by creatnig a custom field for each employee in the page of employers to store his email and pass it to the form on demand.
        I apreciate your help, thanks again!

        • What I’d suggest is to create a custom post type, called “Employer”. It would have a metabox with fields for Phone Number and Email. Then on your Employers page, you query all the Employer posts and print their titles (names) and phone numbers, along with a “Contact Link” that passes the Employer post ID via GET variable.

          Then you have a custom shortcode like CF7_get_employer_email that would query based on the passed Employer ID and retrieve the email meta data and place it in the form via CF7 DTX. Note that there is no way to avoid placing the email on the contact page, but you can use DTX’s obfuscation method to provide at least a little protection.

          If you’re not comfortable with coding custom post types, you might find one of these plugins useful:

          Hope that helps,


          • Hi Chris, It is me again. I have followed your advice to set up an employers page and create enployer custom posts with Name, phone and email metaboxes. Everything so far is perfect I could fetch all the employers information in the employers page and when I click on contact this employer link it takes me to the contact page providing a URL variable like this: http://localhost:8888/ravaca/contacto?contact=265 The variable is the post id of the employer beeing clicked. Now my problem is that I could not figure out how to retrieve the email of the current employer from the METABOX, with the name email, using his id.
            I woulkd be so obliged to you if could tell me how to do that.

        • Actually, I think all you’ll need to do at that point is create a dynamic text field with a modified version of the Custom Fields shortcode. Like this:

          function cf7_get_custom_field_special($atts){
          		'key' => '',
          		'post_id' => -1,
          		'obfuscate'	=> 'on'
          	), $atts));
          	if($post_id < 0){
          			$post_id = $_GET['contact'];
          			global $post;
          			if(isset($post)) $post_id = $post->ID;
          	if($post_id < 0 || empty($key)) return '';
          	$val = get_post_meta($post_id, $key, true);
          	if($obfuscate == 'on'){
          		$val = cf7dtx_obfuscate($val);
          	return $val;
          add_shortcode('CF7_get_custom_field_special', 'cf7_get_custom_field_special');

          Then create your dynamic text field like this:

          [dynamictext employer-email "CF7_get_custom_field_special key='email'"]

          Think that should do it for you πŸ™‚

  37. Hi Chris, thanks for your reply again. Can you please tell me where to place the function above. do I have to place it in the contact.php template? I have tried it this way but once in contact page I get a blank window. I am really confused and I have to solve this issue.

  38. Sorry for my ignorance. At last I could make it work. I appended the custom function to your plugin and it works super well. Thanks for the excellent plugin and mostly for yopur time.

  39. Hey Chris,

    I love the plug in btw! I just came across it today, but it’s saved me a lot of time already. I’m using it to tag form submissions with user name and email values for better tracking.

    I’ve come across one problem in my testing though. When a user submits a form (CF7), the form does not automatically re-populate the dynamic fields with the values. They are empty once the first submission occurs. This is a problem for me, as one of my user groups require multiple form submissions (using the form for various project updates, and we have many). I’ve put this up on the site too, but came to this site as well. Either way, thanks for the advice/fix in advance! πŸ™‚

    • I was able to resolve this issue by changing the line in the CF7 plug-in’s scripts.js file from:

      if (1 == data.mailSent) {


      if (1 == data.mailSent) {

      Just removed the clear form. It may present a bug, but it’s been working that way now for a while. We’ll see. πŸ™‚

  40. Hi Chis.
    After reading the complete list of questions and solutions I did not find the way I can solve my open question.
    After many hours of searching and trying hopefully you can help me out.
    I try to grab the SlideName of Slidedeck into a dynamichidden field.
    In firebug the SlideName = ‘dl.slidedeck’.

  41. hi there-

    love your plugin. i followed a tutorial and am successfully using the contact form to reply to guest posts using

    [dynamichidden recipient-email "CF7_get_custom_field key='Author Email' obfuscate='on'"]

    The guest posts have there email addresses in a custom field and contact form is pulling that data from the custom field and using that as the email address to send it to. this works perfectly, the only problem is that if you view the source (via developer tools or firebug) the email address is viewable. how do i fix that? piping is not an option, as there is no selection process….

  42. Hey Chris,

    I’m interested in using the values from one form (CF7) to populate some of values in another. For example, if a form on the landing page had a couple text fields for say, zip and name, is it possible to take those values and inset them into another form on another page, say a contact page?

    I’ve asked this question on the wordpress site as well, but I’m really interested in a solution. πŸ™‚

    • Hey Charles,

      You could do it by using a normal form on the first page and submitting its values to a second page, which contained a CF7 form. On the CF7 form, you could retrieve the GET or POST values that were submitted.

      I don’t think you’d want to use two CF7 contact forms, as they would both result in emails being sent; it would also require some modifications, as CF7 uses AJAX by default (so the second page wouldn’t load).

      Hope that helps,


  43. I’m working on a site in which people can choose one category they ‘belong to’. I’m looking for a way to populate a dropdown menu that contains a list of all the categories on this website (exluding one or two). It would be great if something like a wp-list-categories function could be used in place of the choices I now have to enter manually in the form. With a few hundred categories (and changing) it would be awesome to have this done automatically. I think it can be done, but have no idea how ;).

      • Thanks. This would really save a lot of time and connect existing WP content with the form. By the way, multiple choices from a dropdown would also be great, but I believe that would require some javascript.


  44. Hi Chris
    Great plugin, works like a charm! I just need help to pass the variable to the email. In my case I’m getting the subject but I’m not able to capture it. My field is [dynamictext dynamicname “CF7_GET key=’subject'”]. I did try with key=’subject’, subject and more but it fails…

  45. Thanks Chris,
    I’m a dumb I didn’t change the field name value… I was using “dynamicname” LOL
    Now I want to know if it’s possible to add tabindex values to the dynamic field. Using tabindex=’6′ or tabindex:6 doesn’t work for me

  46. Pingback: Karesansui on "Can fields be initialized with php code ?" | Ϊ―Ω€Ω€Ω€Ω€ΩˆΪ―Ω€Ω€Ω€Ω€Ω€Ω€Ω„

  47. Hi there, amazing plugin, love it!
    I have a question for you though and I’d really appreciate your thoughts… I have a real estate website built using the WP-Property plugin. This plugin generates property stats, one of which is the property’s address, and I would like to populate a dynamic text filed with the address. Currently the form pulls in the post title.

    Any thoughts on what I would need to do to achieve this?
    Property Listing Example

    Thanks, appreciate your help.

    • Hi Josh,

      The values are likely custom meta fields attached to the posts, in which case you could use the custom field shortcode to grab the value:

      [dynamictext dynamicname "CF7_get_custom_field key='my_custom_field'"]

      Otherwise, you can just wrap whatever function normally retrieves the values and wrap it in a shortcode in order to pull that value into the form πŸ™‚

      Hope that helps!


      P.S. The fact that you have a Dunedin-based site is awesomely coincidental – I used to live on Regent Road when I studied abroad at University of Otago! πŸ™‚

      • Chris your a legend, worked like a charm. Thanks for your help!

        That’s definitely a cool coincidence alright… pretty small world… You can’t beat the 24hr shop at the bottom of Regent for a quick greasy feed on the way home from all those pubs and clubs haha. Perfect stumbling distance from town!

        Thanks again for the quick easy help.

        • No problem! Glad it worked for you.

          Haha yeah I remember that place, made plenty of stops in there when I was too lazy to head down to the Countdown, too. Ah, good memories πŸ™‚

  48. I dont think this plugin works with Contact Form 7 3.0, or is it just for me.
    My custom field value is not there anymore.

    • Thanks for the heads up. I just took a look at the new version (didn’t know there was one till now) and as much of it has been rewritten, CF7 DTX may also need to be rewritten. Hopefully I will have some time for this soon.



  49. Hey, can your plugin pull in fields from a previous filled in form on another page.


    On my home page I have a quick form with 3 fields Name, Contact Number and Email Address once the user has submitted the details it take them to another page

    i would like the previous page form details to be populated in the same fields but there will also be more details for them to fill in and submit.

    Can you plugin help me do this? and if so what are the short codes i need to implement ?


    • Yes, that’s exactly what it does. Once you submit a form, you can retrieve those variables on the next page via the CF7_GET or CF7_POST shortcodes included with CF7 DTX. All the details you need are in the plugin description, and this tutorial may help as well

      One caveat: I’ve heard reports that CF7 DTX isn’t working with Contact Form 7 3.0, which was released a few weeks back. I haven’t had time to investigate this myself yet.

    • Hi Chris

      Do you know in the meantime any solution or workaround for your plugin with CF7 3.0? I was so happy with your plugin in the past.

      Best regards

    • Hi Michael,

      I’ve tested a variety of installations with WordPress 3.2.1, Contact Form 7 3.0.1, and Contact Form 7 Dynamic Text Extension, and I haven’t had any issues whatsoever. I’ve only had one reported case of there being a problem with version 3, and that seems to be isolated. Seems I jumped the gun by suggesting there might be an issue based on a single report.


  50. Excellent work on the plugin.

    I was wondering if you could tell me if it’s possible to do this with your plugin or could offer any advice.

    I’m using the plugin to populate a referrer field on a contact form, this is a link that would be individual to people sending business to the site and contains their unique value.

    This works fine but if the user leaves the page then comes back to it via the sites normal navigation the field is blank again.

    What I’d like to do is be able to save the value in the link to the cache for a certain amount of time so that if they leave the contact form page and come back from another link it will still be populated.

    Any help is really appreciated.

    • Hi Ste,

      I think what you’ll want to do is write a shortcode that grabs the referrer value and saves it in a cookie or session, and then retrieves that value from the cookie if the referrer URL variable is unavailable. You could base your shortcode on the one you’re currently using (for example, CF7_GET).

      Hope that helps!


  51. Thanks, that did help, I created a new short code and added it to the plugin file

    /* Insert the referrer id via url or cookie */
    function cf7_referrer(){
    if(isset($_COOKIE["Referrer"])) { $val= $_COOKIE["Referrer"]; } else { $val = $_GET["id"]; } return $val;
    add_shortcode('CF7_REFERRER', 'cf7_referrer');

    and then added to header file

    works just like i wanted. Again great plugin and thanks for you help.

  52. Hello and thanks for the plugin.

    Is there a way you could add an email selection to your plugin. That would over ride or sit along side of CF7’s email?

    I’d like to have the ability of pre populating the email address of current user with validation for email built in.

    CF7 isn’t (haven’t seen movement toward) doing something like this and I thought you might take a look. I’ve searched everywhere and your plugin seems to be very close to accomplishing this.

    Just a thought.


    • As long as the plugin has a way of accessing the data via PHP when the contact form loads, you could write a shortcode to return that data into the form. You could use one of the existing shortcodes as a template if you’re unfamiliar.

  53. Hi there, this plugin seems really neat!!!

    As I’m getting used to contact form 7 and for my previous pages it has worked very very good I don’t know if I’ll install this yet.

    The only thing I’m unable to find/fix/hack is that I need a counter for every sent form. Is there a way to add a code in contact form 7 (or this new plugin) to make it happen? I saw some answers up here but thought it was for contact form 7. Would this work for that plugin too?


  54. Sorry to bother with the same thing you have already posted before…I’ve been studing the code above and tried it with no success.
    Am I supposed then, to change the
    $val = get_option( ‘cf7-counter’, 0);
    $val = get_option( ‘cf7-counter’, 1); ?

    thanks a lot, it means so much for me a recent student in php :/

  55. Hello. This plugin seems great. Im trying to create a order form for my customers that show different fields depending on the selection of the first field. For example.

    If the customers answers YES on question 1 a new field will pop up that asks them to answer a new question. Would look something like this

    Question: Will you need to move your current suscription from a different carrier?

    IF NO is selected no further question will appear

    IF YES new fields will appear where the customer can add further information concerning his current carrier.

    How can i make this work?

    • Hi Johannes,

      This plugin sets dynamic values in the form; it doesn’t make the form fields display dynamically.

      A good approach for your scenario would be to use javascript to show the appropriate form elements.

      I’d group your form elements into fieldsets and then write some JS logic to show and hide them as the field values change. It’d be pretty easy to do with jQuery.

      Hope that helps,


  56. Hi Chris,

    Thanks for the wonderful plugin. I am looking to populate the form with some dynamic text which varies with the button pressed and redirects to the contact form. I was able to populate the form with some required text , but could not change it based on the button that redirects the page to the form. Please help me out in this issue.

    Sravan Dharmabotla

    • Hi Sravan,

      Glad you like the plugin. You’ll either want to have multiple forms with submit buttons submitting different form values, or just use links as buttons that submit different GET parameters. For example:

      Button 1
      Button 2

      Then use the CF7_GET shortcode to retrieve the value.

      Hope that helps πŸ™‚


  57. Hi, Chris

    Your plugin solved many of my problems, I love it!
    However, I still can’t figure out how to use short code to show the slug of the current category (My contact form is located at category pages). Wondering if you can help me out… I added following code:

    function cf7_get_current_location($atts){
    'key' => 'slug',
    ), $atts));

    get_the_category( );

    $val = $category->$key;
    return $val;
    add_shortcode('CF7_get_current_location', 'cf7_get_current_location');

    then added the short code CF7_get_current_location, it doesn’t work….
    Please help. Thank you


    • Hi Ann,

      I think if you use get_the_category() without passing a post ID, you need to be in the Loop – and I’m guessing your contact form is outside the loop, so that’s why it isn’t working.

      Here’s a function that gets the current category on the category page:

      $cat = get_category(get_query_var('cat'),false);


      So then you’d have something like this:

      function cf7_get_current_location($atts){
      $cat = get_category( get_query_var( 'cat' ), false );
      return $cat->slug;
      add_shortcode('CF7_get_current_location', 'cf7_get_current_location');

      Hope that helps πŸ™‚


  58. Hello,

    I’m trying too use your plugin in combination with the easy modal plugin.
    Im using this in my form:
    [dynamichidden dynamichidden-336 “CF7_get_post_var key=’title'”]
    [dynamichidden dynamichidden-922 “CF7_URL”]
    and this in my mail:
    Url: [dynamichidden-922]
    Titel: [dynamichidden-336]

    Now the title stays empty and the URL shows the url of te easy modal plugin. How can i show the post URL and Title in my mail?

    • Hi Patrick,

      I’m not familiar with the Easy Modal plugin, but my guess is that it uses AJAX to retrieve the contact form – since that is technically not loading a post page, you wouldn’t be able to get the post information, and the URL will be the AJAX URL. If you want to get the values from the initial page, you might try passing them via the AJAX request. Or, you could insert the contact form directly into the page, then remove the inline content and place it in the modal on page load, which should solve the issue as well.

      Hope that helps,


  59. Hi Chris,
    Thanks so much for a great plug-in…. exactly what i was looking for! My only problem is when I use the dynamichidden field, it also hides the label for the following field and just shows an empty text box with no label (even stranger, I’m able to add text to the text field, but when the email is sent, the text field is blank). I moved the dynamichidden field to the bottom of the form (since it doesn’t really matter where it is), but now the “success” message doesn’t show. I’ve tried adding tags around it and tags and anything else that may separate the hidden field from the rest of the form, but no luck. Any idea why this is happening and what I can do to fix it?

    • Hi Libby,

      That’s strange, I’ve never seen that before. I just tested this locally and wasn’t able to recreate the issue. Can you post a link to your site? It sounds like a tag is being left open someplace, or an attribute has a quote inside it (causing unmatched quotes). Is the value returned by the shortcode valid to be set in an HTML attribute? It could be creating invalid markup.


  60. Wow – thanks for the fast response!

    the link is There should be “Personal Details” at the top and then “Your name” next to the lonely text field, but they are hidden.

    sounds like it may be something wrong with my shortcode? I used the following to grab variables from the url (my shopping cart script was originally set up to link directly to paypal, but I hacked it a bit to redirect to the page with my contact form):

    function cf7_libby(){
    $pageURL = ”;
    foreach($_GET as $key => $value) {
    $pageURL .= $key . ‘ : ‘ . urldecode($value) . “rn”;
    return $pageURL;
    add_shortcode(‘CF7_LIBBY’, ‘cf7_libby’);

    Then in the contact form i put:

    [dynamichidden quotation “CF7_LIBBY”]

    Am I missing anything?

    Thanks so much!

    • Hi Libby,

      I think the problem is the urldecode() call, but I can’t be sure.

      This is the markup it’s producing:

      As I suspected, the value being returned from your shortcode is breaking the value attribute (it can’t have HTML or quotes inside it).

      I think the rn will also likely break it, so I’d remove that as well.

      Hope that helps πŸ™‚


  61. Hi! Great plugin and I have been using it a lot, but seems broken now with WP 3.3? Have you tested it there? Especially the dynamic hidden doesn’t seem to be working now.

    Can you help me? Thanks πŸ˜‰

    • Hi Elmar,

      I just tested with CF7 3.0.1 and WordPress 3.3, and things seem to be working for me. Anything specific that’s going wrong? Or code/link to your site?


  62. Chris

    I’m using CF7 for a basic Contact Us function. I’d like the email addresses to rotate every 7 days. It would replace the email with the next one on the list of 3 and start over when it goes through all three. Will your plugin make this possible?

    Thanks in advance for any help!

    • Hi Priscilla,

      If you wrote a custom shortcode that returned the appropriate email address you could achieve that. πŸ™‚



  63. Hello again i thought I responded but evidently not. Thank you so much for the plugin and the help. I don’t know how to write the shortcode and will gladly compensate you for the help. What I need:

    Rotate email address receiving info from submitted form every 7 days using 3 addresses.

    • Hi Priscilla,

      I’m sorry, I don’t have much time to spend on freelance work right now, but here’s what I’d do:

      1. Use wp_schedule_event to set up a weekly event that updates the email address option in the database via update_option();

      add_action('priscilla_weekly_event', 'update_email_weekly');

      function priscilla_activation() {
      if ( !wp_next_scheduled( 'priscilla_weekly_event' ) ) {
      $time = time(); //set this to the UNIX timestamp of when the first change should occur
      wp_schedule_event($time, 'weekly', 'priscilla_weekly_event');
      add_action('wp', 'priscilla_activation');

      function update_email_weekly() {

      $emails = array(
      1 => '[email protected]',
      2 => '[email protected]',
      3 => '[email protected]',

      $current = get_option( 'cf7-email', '[email protected]');
      $next = '';
      foreach($emails as $k => $email){
      if($current == $email){
      if($k == 3) $next = $emails[1];
      else $next = $emails[$k+1];

      update_option( 'cf7-email' , $next);


      2. Create a shortcode to simply retrieve that option from the DB. Something like:

      function cf7_get_current_email($atts){
      return get_option( 'cf7-email', '[email protected]');
      add_shortcode('CF7_get_current_email', 'cf7_get_current_email');

      That should pretty much do it. Hope it helps πŸ™‚


    • Chris

      Sorry to be taking your time up with novice questions. The last thing I need is exactly where to drop the code in. I was thinking of adding the main code into Additional Settings on the form and the short code provided into a hidden dynamic field however I realized I have no idea what I’m doing when the short code field in dynamic text truncated. Should have realized it sooner but thought I’d give it a whirl. Do you mind going so far as to telling me where to put these items. Also I’m thinking something should go into the “To” field under Mail but not sure what to put in there since it seems to have a character limitation as well.

      Thanks very much,

  64. Hi, I’m sorry to ask this again as you have said to Charles,
    I’m interested in using the values from one form (CF7) to populate some of values in another. For example, if a form on the landing page had a couple text fields for say, zip and name, is it possible to take those values and inset them into another form on another page, say a contact page?

    Hey Charles,

    You could do it by using a normal form on the first page and submitting its values to a second page, which contained a CF7 form. On the CF7 form, you could retrieve the GET or POST values that were submitted.

    I don’t think you’d want to use two CF7 contact forms, as they would both result in emails being sent; it would also require some modifications, as CF7 uses AJAX by default (so the second page wouldn’t load).

    I would like to do the same, I use one form to gather signature for a petition the email goes to the relevant person and on submit redirects to a donation page which goes to my client.

    What we would like to do is pass over the first name, last name etc of the petitioner to help speed up filling in the donation form.

    I can pre fill to form using the on_sent_ok: “location…/?firstname=first-name&etc. but I cannot get the data from the form into this string.

    Is there a way to do this or another way to get the same results.

    Thanks for your hard work.

    • Hi Stuart,

      Sorry, that’s a little beyond what I can go into here. If you’re saying you’ve got 2 CF7s, and want to use data from the first to populate the second, I think you’d probably want to use cookies. Since the form submits, then redirects, the submitted vars wouldn’t be available on the redirect page. I think your best bet would be to collect them and save them in a cookie, then retrieve them using a custom shortcode in the second form.

      Alternatively, if you can control the redirect page URL, just grab those values and put them into the redirect URL via the shortcodes or normal PHP $_GET or $_POST vars.

      Hope that helps πŸ™‚


  65. Hi thanks for the great plugin, have read through all of the posts but am struggling.

    I have a table with some basic info in it about some courses.

    I would like to pass two of the td’s to a contact form with a href. The last field on the form would be the link. I have tried lots of different methids mentioned here but getting no where.

    basically there are 3 tabs one with group courses one with individual courses and a third tab with the form.

    so all i need to do is link back to the same page and fill the form in.

    any ideas why i cant get it to work?



Comments are closed.