WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Can it do this? (16 posts)

  1. dclardy
    Member
    Posted 3 years ago #

    I am converting a site from php to wordpress. The site has a contact form in the sidebar that post the information to a larger version of the contact form. The user then fills out the information and submits the second form.

    Can contact form 7 be used to do this? If not, any suggestions?

  2. dclardy
    Member
    Posted 3 years ago #

    I just wanted to add some more information about what I am trying to do.

    The user inputs First Name, Last Name, and Phone Number in the smaller version of the form. When they press submit, they are taken to the contact page with the information already submitted filled in on the larger version of the same form. They can then answer some more questions. They press submit on the large version of the form, and it sends the email.

  3. dclardy
    Member
    Posted 3 years ago #

    Any ideas here?

  4. sevenspark
    Member
    Posted 3 years ago #

    Well, I think you'd want to use a regular form (not a Contact Form 7 Form) for the first form (otherwise you'll end up sending two emails). You could submit this form to a page with a Contact Form 7 Form on it, and collect the GET variables into the larger form using the Contact Form 7 Dynamic Text Extension: http://wordpress.org/extend/plugins/contact-form-7-dynamic-text-extension/

  5. dclardy
    Member
    Posted 3 years ago #

    What would use to create the first form? Could the larger form be used by itself? If the values are empty, how does it function?

  6. sevenspark
    Member
    Posted 3 years ago #

    You'd create the first form with normal HTML form syntax. Just point it at the URL of the Contact Form 7 page. Something basic like:

    <form name="smallform" action="the_cf7_big_form_page_url" method="GET">
    First Name: <input type="text" name="name" />
    <input type="submit" value="Submit" />
    </form>

    Yes, you could use the larger form by itself. When the values are empty, the dynamic field functions as a normal text field. In other words, the default is set to an empty string rather than a dynamic value.

  7. dclardy
    Member
    Posted 3 years ago #

    Alright. I have created the form, and I am trying to get it to work properly. I am posting the data to the address bar, but it is not being placed into the form correctly.

    Here is what I am seeing:

    http://testing.optimusbusinessplans.com/contact/?first-name=Bob&last-name=Smith&day-phone=xxx-xxx-xxxx&their-email=bob@bob.com

    Here are the values for the fields.

    <p>First Name (required)
        [dynamictext* first-name "CF7_GET val='first-name'"] </p>
    
    <p>Last Name (required)
        [dynamictext* last-name "last-name"] </p>
    
    <p>Daytime Phone Number (required)
        [dynamictext* day-phone "day-phone"] </p>
    
    <p>Email (required)
        [dynamictext* their-email "their-email'] </p>
  8. sevenspark
    Member
    Posted 3 years ago #

    First off, they should all be in the same structure as the first-name field, i.e.:

    [dynamictext* last-name "CF7_GET val='last-name'"]
    [dynamictext* day-phone "CF7_GET val='day-phone'"]
    [dynamictext* their-email "CF7_GET val='their-email'"]

    Given that you're seeing the shortcode rather than the input box, are you sure you (a) installed and (b) activated the Dynamic Text plugin?

  9. dclardy
    Member
    Posted 3 years ago #

    It is installed and activated. I was changing them around to trying to get it to work. I do need to change those other ones back.

    Does this not work with the latest wordpress?

  10. sevenspark
    Member
    Posted 3 years ago #

    Definitely works on the latest WP. Looks like it may be a dependency issue, I'll look into it and get back to you.

  11. sevenspark
    Member
    Posted 3 years ago #

    Greetings dclary,

    I have released a new version of the Dynamic Text Extension - version 1.0.1. Please download and install this update. This should fix the dependency issue that you were having (basically, this was being loaded before the Contact Form 7 Plugin, and the dependency was broken).

    Also, please replace "val=" with "key=" in your dynamictext shortcodes. It should look like:

    <p>First Name (required)
        [dynamictext* first-name "CF7_GET key='first-name'"] </p>
    
    <p>Last Name (required)
        [dynamictext* last-name "CF7_GET key='last-name'"] </p>
    
    <p>Daytime Phone Number (required)
        [dynamictext* day-phone "CF7_GET key='day-phone'"] </p>
    
    <p>Email (required)
        [dynamictext* their-email "CF7_GET key='their-email'"] </p>

    I set up a temporary test page so you can see how it's working on my site: http://sevenspark.com/testing-wpcf7-dynamic-text-extension?first-name=John&last-name=Smith&day-phone=999-999-9999 (email left blank to show how it works without a value.

    Hope that works for you!

    Chris

  12. dclardy
    Member
    Posted 3 years ago #

    It works great. Thanks a ton for the help. Great plugin by the way.

  13. sevenspark
    Member
    Posted 3 years ago #

    You're welcome! Glad to hear it worked out :) And thanks!

  14. dclardy
    Member
    Posted 3 years ago #

    Here is another question on this:

    Everything is working fine, but there is an issue with IE. I am sure that this is not plugin related, but I was hoping that you could help.

    In chrome and firefox, the small form post this information to the address bar:

    http://testing.optimusbusinessplans.com/contact/?first-name=Bob&last-name=Smith&day-phone=555-555-1212&their-email=bob%40gmail.com

    In IE, it does this:

    http://testing.optimusbusinessplans.com/contact/?first-name=Bob&last-name=Smith&day-phone=555-555-1212&their-email=bobgmail.com

    Is there anyway to get the @ to show up in IE.

  15. sevenspark
    Member
    Posted 3 years ago #

    I haven't heard of this Internet Explorer glitch in the past, but I'm not terribly surprised to hear it exists. I'm not sure what version of IE you're using (perhaps this has been fixed in a newer version), but regardless, you want this to work for everyone anyway. I searched around a bit for solutions, but didn't actually find this bug documented anywhere.

    You could use a JavaScript solution, but that's a bit complicated and not good for accessibility.

    You understand that the reason this is an issue at all is because non-valid URL characters (like spaces, the @ sign, etc), need to be encoded in the URL (that's what the %40 is). It seems that while Firefox and Chrome successfully encode the character, IE just drops it (in your case at the least).

    So, instead of using GET, a simple solution would be to use POST. With POST, the variables are not encoded in the URL, and we sidestep the problem entirely. Just do the following:

    1. Change your small form's method attribute to "POST"
    2. Add a shortcode to handle grabbing POST variables. It'd look something like this:

    function my_get_post_value_fcn($atts){
    	extract(shortcode_atts(array(
    		'key' => -1,
    	), $atts));
    	if($key == -1) return '';
    	$val = $_POST[$key];
    	return $val;
    }
    add_shortcode('get-POST-value', 'my_get_post_value_fcn');

    3. Change your dynamic text values in the Contact Form to something like:

    [dynamictext* email "get-POST-value key='email'"]

    (You'll use the new POST function for all of them.)

    Note that I haven't tested these functions. I'll also add a POST shortcode like the one I described to my list of updates for the next plugin release.

    Hope that helps!

  16. dclardy
    Member
    Posted 3 years ago #

    That works just fine. Here is what I ended up using. It follows your previous convention of naming. You could probably just paste it in.

    function cf7_post($atts){
    	extract(shortcode_atts(array(
    		'key' => -1,
    	), $atts));
    	if($key == -1) return '';
    	$val = $_POST[$key];
    	return $val;
    }
    add_shortcode('CF7_POST', 'cf7_post');

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic