| Post |
|
Alvaro - Guest
11:57 pm - March 14, 2008
|
| |
|
Hi Oliver,
is there a possibility to extract the value from the url (variables) in some way similar as we can do with the custom fields?
Regards,
Álvaro
|
|
|
Oliver
- Admin
2:11 am - March 15, 2008
posts 3562 |
| |
|
Yes, you can supply the field id in the URL, e.g. ?cf_field_1=123 and it will preset that field in the form accordingly.
|
|
|
Alvaro - Guest
7:48 pm - March 15, 2008
|
| |
|
Hi Oliver,
thanks for the fast response. My intention wasn't exactly this poing, but it's good to know.
I have changed the source-code from cforms.php and added the following code (after line 1374):
preg_match_all('/^[<]{1}[a-zA-Z0-9]+[>]{1}$/',$field_value,$keys); if (count($keys[0]) > 0 ) { $field_value = $_GET[substr($keys[0][0],1,strlen($keys[0][0])-2)]; }
This adds the posibility to extract to value from the url without knowing the id from the field. The onlye thing to do is to add a default value for a hidden file with the format: <value>
Is there a possibilyt to add this to the official code?
|
|
|
Oliver
- Admin
9:51 am - March 16, 2008
posts 3562 |
| |
|
Hi Alvaro,
Sorry for being a bit dense, what is the purpose of the above?
Could you give an actual example?
|
|
|
Alvaro - Guest
3:50 pm - March 16, 2008
|
| |
|
Hi Oliver,
when you do online marketing, you have tracking variables -in the url-, like campaing, keyword, referal....
With the solution you gave me, you have to have the hidden field always in the same position (id), but with my position the id of the field doesn't matter.
|
|
|
Oliver
- Admin
5:33 pm - March 16, 2008
posts 3562 |
| |
|
I see where you gain some flexibility but fail to see how that would -bottom line- differ from simply using the existing method.
E.g. your way allows hiddenfield_1 to be preset with GET key test123
The calling URL could be URL.com?test123=somevalue and you end up with hiddenfield_1 = somevalue
My current method only needs to know the ID of hiddenfield_1 to achieve the same result, with the difference being in the URL:
URL.com?hiddenfield_1_ID=somevalue
Of course if you don't have any influence on the URL, then, I agree, your way is the only possible of the two.
|
|
|
Alvaro - Guest
9:08 am - March 17, 2008
|
| |
|
Hi Oliver,
i'll show you an extreme case. When you track Google AdWords Campaings automatically, the url is created by Google and i'm unable to change the variable (gclid).
Another aspect is, that a variable called "hiddenfield_1_ID" isn't as "pretty" as for example "ref".
What do you think?
|
|
|
Oliver
- Admin
7:05 pm - March 17, 2008
posts 3562 |
| |
|
Makes sense, and the code snippet is small enough to not add much to the code base. I'll add it going forward. Thanks!
|
|
|
Alvaro - Guest
7:44 pm - March 17, 2008
|
| |
|
Hi Oliver,
thanks for considering to add this code to the plugin. Cforms is one of my essential plugins in WP.
I'll be looking forward to help you adding new functionalities.
Regards,
Álvaro
|
|
|
Pauli Price - Guest
5:48 pm - October 6, 2008
|
| |
|
Oliver,
Has this feature been added to the code? I didn't see any mention in the documentation.
I have the exact use case mentioned, Google AdWords campaign tracking, and want to know how to add url values to hidden fields in my form data.
I'm hoping that if the url has
site.com?keyword=advertising search term&adgroup=adgroup_id&creative=creative_id
then in hidden fields would I specify as follows?
field name 1|{keyword}
field name 2|{adgroup}
field name 3|{creative}
Is this the case for the current release? Or would it be the case if I added the code fragment provided earlier in the thread ( in case you haven't included it yet ) ?
I'm not certain of the syntax to access these values, as the original poster uses angle brackets in his post, and I don't see the use of angle brackets anywhere in the documentation.
Thank you so much for your plugin -- I think it's wonderful!
Pauli
|
|
|
Oliver
- Admin
10:31 pm - October 6, 2008
posts 3562 |
| |
|
If you'd like to preset the hidden field by providing the value in the URL, e.g.
then you need to make sure to give your hidden field the ID 'ref', by specifying it in the config string:
my_hidden_field_1[id:ref]
(and turn on 'custom names/id's' in your form config)
|
|
|
rz1 - Guest
11:06 am - October 8, 2008
|
| |
|
Hello Olivier,
The method below work perfectly.
But if the value in the URL are in uppercase, and if I give my hidden field the ID in uppercase, this don't work.
my_hidden_field_1[id:UPPERCASE_ID]
In the page source code, ID is converted in lowercase
...name="uppercase_id" id="uppercase_id"...
Anyway to fix this ?
|
|
|
Oliver
- Admin
9:11 pm - October 12, 2008
posts 3562 |
| |
|
I guess only in the code, need to check why I set it to lowercase, if there isn't any particular reason such as form nomenclature/conventions (can't remember) I might remove the lower case...
|
|