cforms II User Forum

Registration is currently disabled.
Guest

FAQs

Login form protected by Login LockDown.


Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
prepopulate fields with data from post
July 23, 2008
6:00 am
David Hutchison
Guest

Please replace the ??? with your data!

  • Your URL: none – local install for testing
  • The browser used: safari
  • cforms version:8.5.2
  • Your Wordpress version: 2.6

I have many posts which each describe an organization, with contact information etc.

I would like to use a cform as a contact form so that a user can send an email to that organization, without publicly revealing the contact email address.

Can I use data from the post – the title which is the name of the organization – and perhaps a custom wordpress field in the post to hold the email address – to prepopulate a contact form.

Also, assuming I can prepopulate, I can only see the tell-a-friend as a way but it will not keep the email address hidden – I cannot see how to hide this field.

Any help wold be really appreciated!
_

July 23, 2008
7:48 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Yes you can. See this thread (it's the same requirement).

July 24, 2008
9:41 am
David Hutchison
Guest

Thank you! I have spent a good deal of time trying this but still have one error I can't handle.

Firstly, in the example yo suggest creating a custom field called "email_address" and then proceed to use dir_listing_email in the example code. Assuming I'm right, no big deal. 

That said I think there is some issue with these lines:

$dle = get_post_custom_values( 'dir_listing_email', $pid );

$dle = implode($dle,', ');

$m = str_replace( '{dir_listing_email}', $dle, $m );

I say that because if I comment out the first two lines and add one saying:

$dle = 'bill@microsoft.com';  // well of course my email address actually

then it works just fine.

I've tried the 'get_post_meta' option for retrieving and that's no good either.

Yes, I spelled the custom key name fine…

Can you see anything? Is there a way to echo the contents of dle to see what is pulled from the custom key? I trust a simple echo won't do the trick…

July 24, 2008
10:25 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline
Yep, the first "suggestion" (email_address) was merely an example.
    I've tried the 'get_post_meta' option for retrieving and that's no good either.
Odd. This was off top of my head, but still, I can't see anything wrong with it, not from a principal point of view anyway.
Check "$pid", if it indeed contains the proper post ID otherwise get_post_custom_values won't work.
Can you see anything? Is there a way to echo the contents of dle to see what is pulled from the custom key? I trust a simple echo won't do the trick…
sure, just add
echo "pid = ".$pid;
and make sure you try submitting your form with Ajax disabled (otherwise you won't see the echo).
July 24, 2008
11:17 pm
David Hutchison
Guest

Thanks for this – I had tried echo but not disabling AJAX.

Now I'm thoroughly confused. echo shows that the correct email address is being pulled from the post.

I hit submit on the form and get taken to a blanked out version of the post page which I imagine is a non-ajax place that a message might be displayed? Anyway, no complaints and it seems to work – but no email comes through. I'm assuming this could well be that I now have my machine connected wirelessly on another network and my mail server settings could well be wrong – I'll need to test this part at home tonight. However…

When I go back to AJAX mode – and I trust the email address is pulled still fine since the code I was using echo in is in lib_aux.php but I get my message again about needing to supply one recipient email address…

The only difference I see in lib_aux is in the first if / else-if construct that assigns pid where the lines:   

else if($ Ajaxpid <> '') 

   $pid = $Ajaxpid;

have me wondering if the pid can be assigned differently in Ajax mode?

Thanks for all your help – it really is appreciated and while frustrated – I'm learning lots which makes it worth the effort!

July 24, 2008
11:41 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Right, for the Ajax version to pull the right email address, you need to enable (on your cforms form config page), I missed to mention that:

Extra variables
e.g. {Title}

in Core Form Admin / Email Options.

Generally, testing in nonAjax mode is more practical due to being able to use 'echoes'. You could for instance have a test echo in lib_nonajax.php, just before

@mail($to…

to print $to, which should be the email address from the custom field.

July 25, 2008
12:09 am
David Hutchison
Guest

Thank you!

No net connection now but this time it's an SMTP error so it sounds like success.

September 2, 2011
9:48 pm
ArleyM
Guest

Oliver said:

Yes you can. See this thread (it's the same requirement).

Nooooooooooooooooooooooooooooooooooo…. dead link. Would really like to know!

 

I'm trying to pass a product name to the form to populate a select dropdown box. I bet that was the title of the post.

Forever alone.

September 30, 2011
5:00 pm
ArleyM
Guest

So very alone.

September 30, 2011
5:10 pm
ArleyM
Guest

I found where the link is supposed to go! I read through it and it's completely way over my head. These instructions would be good enough if I was trying to tweak the email as in your example, but I'm trying to use a URL string to populate a Products Select input.

 

If I knew the lines of code to update that would be exceedingly helpful. Otherwise this code is a bit scary – I feel like the ramifications of changing this code could be huge. Any help would be amazingly helpful.

 

Thanks!

October 7, 2011
5:10 am
robi
Guest

Oliver said:

Yes you can. See this thread (it's the same requirement).

dead link. can someone give me the tutorial ?

December 7, 2013
4:27 am
benz1
Guest

robi said
I found where the link is supposed to go! I read through it and it's completely way over my head. These instructions would be good enough if I was trying to tweak the email as in your example, but I'm trying to use a URL string to populate a Products Select input.

 

If I knew the lines of code to update that would be exceedingly helpful. Otherwise this code is a bit scary – I feel like the ramifications of changing this code could be huge. Any help would be amazingly helpful.

 

Thanks!

Did you every find a way of doign this? I'm trying to do exactly the same, i.e., pre-populate an option in a Select Box based of a URL string. I've worked out that adding #cf3_field_6 to the URL forces focus onto the select box field but can't figure out how to select an option from the list.

Can anyone assist? Thanks.

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

tracedef: 43

mores: 21

Gyrus: 20

frozenwaste: 18

asuffredini: 15

photoworks: 14

Member Stats:

Guest Posters: 3762

Members: 1463

Moderators: 3

Admins: 2

Forum Stats:

Groups: 1

Forums: 4

Topics: 5361

Posts: 18742

Newest Members: juredujmovic, dreamkeeper, rajattyagi, wrokaa, lukass

Moderators: Paul (421), cnymike (8), sonika (95)

Administrators: Oliver (6400), Nicky (3)